With SqlBulkCopy, the timeout has elapsed.

.net asp.net sql sqlbulkcopy sql-server

Question

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.
1
29
12/26/2010 9:45:05 PM

Accepted Answer

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

38
12/26/2010 9:49:02 PM

Popular Answer

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



Related Questions





Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow