我觉得我错过了一些小事。这个btnSave_Click事件处理程序应该更新我的数据库——我错过了什么?我没有收到任何错误消息。
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
string mainconn = ConfigurationManager.ConnectionStrings["myConnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn);
sqlconn.Open();
SqlCommand sqlcomm = new SqlCommand();
String sqlquery = "INSERT INTO dbo.TestTable (EDIPI) VALUES(@EDIPI)";
sqlcomm.CommandText = sqlquery;
sqlcomm.Connection = sqlconn;
sqlcomm.Parameters.Add("@EDIPI", SqlDbType.NVarChar, 5).Value = txtEDIPI.Text;
sqlconn.Close();
}
catch (Exception exp)
{
MessageBox.Show("Error is " + exp.ToString());
}
}