.Net (2.0, 3.0, 3.5), C#, Asp.net, Com+, GIS(ESRI Software), Management, Analysis & Design, Life, Trips, And more...
- SqlBulkCopy in a new powerful feature in ADO.NET 2.0 which let you to load large amount of data into Sql Server table.
- It provides you the same functionality as the bcp command-line, with significant performance advantage. Furthermore, all this occurs in standard manage code!
- In order to use the SqlBulkCopy you must use Sql Server Table as a target table. But in the source, you can use any source which can loaded into DataTable or to implement the IDataReader interface.
- The SqlBulkCopy class has his private connection timeout definition. So if you specified a timeout period as a part of the connection string, it'll ignore it.
- There is a really weird behavior when using some specific number of rows. The error we got when we tried to use the SqlBulkCopy is:
The incoming tabular data stream (TDS) protocol stream is incorrect. The TDS headers contained errors.
The official symptom for this error is when you using SqlBulkCopy to copy some rows from DataTable into SqlServer 2005 table. In most of the time it works perfect, but for some rows number the SqlBulkCopy.WriteToServer() throw a timeout exception.
It happened to us in my current workplace and after we installed the appropriate hotfix (restart required), this problem has been solved.