SqlBulkCopy.BulkCopyTimeout Property

I am using VSTS 2008 + C # + .Net 3.5 + ADO.Net to develop a console application for bulk copy paste.

I want to use both mass investment and mass investment. For the BulkCopyTimeout property, I am confused and want to know if this applies to the entire mass or applies only to each batch of the main file?

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

thanks in advance George

+4
source share
4 answers

Searching and reading some blog posts and forum posts on the Internet seems to indicate that SqlBulkCopyTimeout does not really apply to the entire operation, but to each batch in the operation.

MSDN docs are not well understood, but most messages seem to indicate that a timeout is applied to the packet. Decreasing the batch size and / or increasing the SqlBulkCopyTimeout seems to be the solution to timeout problems in most cases.

See this forum for an example .

Mark

+7
source

This applies to the entire operation for one batch. You must ensure that connection timeouts are also set. I hit the timeout earlier, set it on a bulk copy and found that the connection time was also difficult.

It seems that the concept of the whole operation is ridiculous. If he eventually expects more than a timeout at any given time, he will fail. In other words, if reading the package takes longer, it will fail, but if the sum of all the files read is> timeout, you are fine. If it takes too long to write a packet, it will also fail.

But this seems to be a batch package, not all.

+2
source

BulkCopyTimeout: default is 30 seconds

 sqlBulkCopy.BulkCopyTimeout = {time in seconds for one batch} 

BatchSize: By default, the entire data source is a single batch.

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

See this link for more details: Timed out using SqlBulkCopy

We get this "Timed out" exception. if the application cannot insert the data source in 30 seconds.

+2
source

It’s not easy to find the perfect timeout for a bulk copy; if you choose a small timeout, you should not choose a large packet packet, because timeout errors may occur. On the other hand, if you decide to choose a small batch size, you are less likely to get a timeout error from the server; however you are not protected.

My recommendation is to set the timeout indefinitely, namely (sqlBulkCopy.BulkCopyTimeout = 0) and try to choose a large batch size for your bulk copy. At least you cannot have a timeout.

0
source

All Articles