【发布时间】:2013-03-06 07:56:39
【问题描述】:
using (SqlConnection connection1 = new SqlConnection(StringCon))
{
string sSQL = string.Format("UPDATE Guest SET FirstName=@Content WHERE GuestID=@GuestID");
SqlCommand MyCmd = new SqlCommand(sSQL, connection1);
SqlParameter param = MyCmd.Parameters.Add("@Content", SqlDbType.NVarChar);
param.Value = "Tony";
SqlParameter param1 = MyCmd.Parameters.Add("@GuestID", SqlDbType.NVarChar);
param1.Value = GuestID;
connection1.Open();
iResult = MyCmd.ExecuteNonQuery();
connection1.Close();
}
但是由于这个错误,这段代码无法执行
超时。在操作完成之前超时时间已过或服务器没有响应。 声明已终止。
为什么会出现错误以及如何修复它。
【问题讨论】:
-
手动运行该语句会发生什么?可能是表上的触发器耗时太长,或者表上没有索引,或者表被锁定等。