SqlBulkCopy 超时已过期

发布于 2024-10-09 02:05:56 字数 219 浏览 0 评论 0原文

我正在使用 SqlBulkCopy 从 xml 备份恢复表。其中一个表备份大约有 200MB 大,并且有大量记录。

我遇到错误:

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

I'm using SqlBulkCopy to restore tables from xml backups. One of the table backup is ~200MB large and has a lot of records.

I'm having error:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

肤浅与狂妄 2024-10-16 02:05:56

您可能需要增加超时时间。尝试增加 sqlBulkCopy.BulkCopyTimeout 的值 与默认值 30 秒相比。

You probably need to increase the timeout. Try increasing the value of sqlBulkCopy.BulkCopyTimeout from the default which is 30 seconds.

盗梦空间 2024-10-16 02:05:56

有两种方法可以修复此错误:

  • 增加超时,默认为 30 秒,0 表示无限。

     sqlBulkCopy.BulkCopyTimeout = {时间(以秒为单位)}
    
  • 默认情况下减少 BatchSize,它会尝试在一批中插入所有行

     sqlBulkCopy.BatchSize = {您要一次插入的行数}
    

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.batchsize.aspx
http://msdn.microsoft.com/en -us/library/system.data.sqlclient.sqlbulkcopy.bulkcopytimeout.aspx

There are two ways to fix this error:

  • Increase Timeout by default it is 30 second and 0 means infinite.

       sqlBulkCopy.BulkCopyTimeout = {time in seconds}
    
  • Decrease BatchSize by default it try to insert all rows in one batch

        sqlBulkCopy.BatchSize  = {no of rows you want to insert at once}
    

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.batchsize.aspx
http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.bulkcopytimeout.aspx

轻拂→两袖风尘 2024-10-16 02:05:56

更改 SqlCommand 的 CommandTimeout 属性目的。

连接字符串的“连接超时”属性确定 SqlConnection 对象在停止尝试连接到服务器之前运行的时间。

另请更改 SqlBulkCopy.BulkCopyTimeout 属性。

Change the CommandTimeout property of your SqlCommand object.

The Connect Timeout attribute of a connection string determines how long a SqlConnection Object runs before it stops attempting to connect to a server.

Also change the SqlBulkCopy.BulkCopyTimeout Property.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文