With SqlBulkCopy, the timeout has elapsed.

.net asp.net sql sqlbulkcopy sql-server

Question

I'm restoring tables from xml backups using SqlBulkCopy. A table backup with many records is around 200MB in size.

I've got a problem:

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

Most likely, you should lengthen the timeout. Consider changing the default value of sqlBulkCopy.BulkCopyTimeout from 30 seconds to something higher.

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

Popular Answer

There are two methods to correct this mistake:

  • By default, Increase Timeout is set to 30 seconds, whereas 0 signifies unlimited.

       sqlBulkCopy.BulkCopyTimeout = {time in seconds}
    
  • By default, decreasing the batch size tries to insert all rows in a single batch.

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

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlbulkcopy.batchsize.aspxhttp://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