0
我一直在處理從ASP.NET頁面連接到數據庫的問題。我填補了相關的登記表後,我已經準備好,當我點擊完成註冊,我遇到了一個錯誤:通過使用ASP.NET將元素插入數據庫表
這裏是我的代碼:
protected void Button1_Click(object sender, EventArgs e)
{
using (SqlConnection baglanti = new SqlConnection("server=BerkPC-IV; Initial Catalog=Okul; Integrated Security=true;"))
{
using (SqlCommand komut = new SqlCommand())
{
komut.Parameters.AddWithValue("@name", TextBox1.Text);
komut.Parameters.AddWithValue("@midname", TextBox2.Text);
komut.Parameters.AddWithValue("@surname", TextBox3.Text);
komut.Parameters.AddWithValue("@phone", TextBox4.Text);
komut.Parameters.AddWithValue("@country", TextBox5.Text);
komut.Parameters.AddWithValue("@city", TextBox6.Text);
komut.Parameters.AddWithValue("@adress", TextBox7.Text);
komut.Parameters.AddWithValue("@passwod", TextBox8.Text);
komut.Parameters.AddWithValue("@email", TextBox9.Text);
try
{
baglanti.Open();
komut.ExecuteNonQuery();
}
catch (SqlException ex)
{
throw;
}
}
}
}
你應該張貼與堆棧跟蹤整個例外,而不是隻圖像的執行被拋出。它有助於調試。 – Yasser 2014-09-28 06:12:32
好的我現在正在編輯 – user3708524 2014-09-28 07:28:31
沒關係,那編輯不會被批准:P – Yasser 2014-09-28 08:00:40