我正在使用桌面應用程序。我開發了一個用戶輸入數據的表單。當他點擊提交按鈕時,數據被保存在數據庫名稱PakReaEstat中。問題是數據沒有插入到表中,並且出現錯誤:SqlException was Unhandled
。數據沒有從窗體插入到數據庫表中
當我點擊提交按鈕時,它會提示錯誤。 按鈕背後的代碼如下:
protected void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=ali-pc/sqlexpress.PakEstateAgency.dbo");
con.Open();
SqlCommand cmd = new SqlCommand("insert into ClientINFO(Application#,LDAReg#,Size,Name,SDW/O,CNIC,Address,Image,giventime)" +
"values (" + Convert.ToInt32(textBox1.Text) + ",'" +
textBox2.Text + "','" +
textBox4.Text + "'," +
textBox5.Text + "," +
textBox6.Text + "," +
textBox7.Text + "," +
textBox8.Text +
"," + textBox3.Text + ")", con);
cmd.ExecuteNonQuery();
MessageBox.Show("Insertion successfully done");
}
缺少去年5個文本框單引號 –
請幫我... –
你確定你正確地訪問數據庫? – Nath