25
11/2014
The timeout period elapsed prior to completion of the operation or the server is not responding.
C# 连接SQL Server数据库,由于一条语句需要很长的时间,执行的时候若默认系统执行时间,则可能会报错:
The timeout period elapsed prior to completion of the operation or the server is not responding.
需要加上如下代码:
SqlCommand cmd = new SqlCommand(sqlStr, db.Con); cmd.CommandTimeout = 0; //设置执行时间,为0表示直到操作完成 cmd.ExecuteNonQuery();
0 条评论