ITPub博客

首页 > > > The timeout period elapsed prior to completion of the operation or the server is not responding.

The timeout period elapsed prior to completion of the operation or the server is not responding.

作者:Ruiyuan Li 时间:2014-11-25 00:00:00 0 删除 编辑

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();


<!-- -->

原文作者:;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2020-05-21

  • 博文量
    495
  • 访问量
    4826