views:

374

answers:

1

I have 40000 records in my DataTable. I want to insert all the records into SQL Server. I am using vb.net 2008 and SQL Server 2005.

Currently I am using XML to pass from vb.net to SQL Server 2005 but it will give me network error. Is there any other way I can achieve this ?

+2  A: 

Look at the SqlBulkCopy class:

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

ho1
Nice link but i read text file and put in my datatable and now i want to insert that records to sqlserver 2005.
KuldipMCA
Just load the textfile into a `DataReader` and continue with the sample in that link. It should be supported by SQL 2005.Here's a discussion about doing this: http://social.msdn.microsoft.com/Forums/en/adodotnetdataproviders/thread/f6a5274e-0f33-4377-8865-c50f550ce36eOtherwise, as mentioned in that discussion, you could try automating the BCP tool from VB.Net.
ho1