Timeout expired with SqlBulkCopy

这一生的挚爱 提交于 2019-11-29 02:58:02

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

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!