做的所有的update命令都无法更新到数据库里,求大神帮忙看看。
代码:
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["yuelanshiConnectionString"].ConnectionString);
string sql1 = "update shugui set 姓名="+TextBox2 .Text .Trim ()+",学号="+TextBox3 .Text .Trim ()+",院系="+DropDownList1 .SelectedItem .Text .Trim ()+",联系方式="+TextBox4 .Text .Trim ()+",登记状态='1' where 书柜号="+TextBox1 .Text .Trim ()+"";
con.Open();
SqlCommand cmd1 = new SqlCommand(sql1, con);
cmd.ExecuteNonQuery();
Response.Redirect("success.aspx",false);
显示的输出是:
在 System.Threading.ThreadAbortException 中第一次偶然出现的“mscorlib.dll”类型的异常
“System.Threading.ThreadAbortException”类型的异常在 mscorlib.dll 中发生,但未在用户代码中进行处理
程序“[1456] iexplore.exe: 脚本程序”已退出,返回值为 0 (0x0)。
程序“[1456] iexplore.exe: 脚本程序”已退出,返回值为 0 (0x0)。
这是什么问题啊?为什么删除和添加都可以用上面这段代码实现,偏偏更新成功不了?