SQL Bulk Copy:
The simplest way to insert data into the table is to use SQL Bulk Copy class. NET Framework 2.0 contains a class in ADO.NET "System.Data.SqlClient". Need to add the below namespace in order to use this SQL Bulk copy class.
SqlBulkCopy bulkcopy = new SqlBulkCopy(ConfigurationManager.ConnectionStrings["DBConn"].ToString());
bulkcopy.DestinationTableName = "[AN_TBL_Authorized]";
The above code inserts the values to the table.
1) Create instance for bulk copy class and give the connection string of the database.
2) Give the destination table name in which you want to insert data.
3) Here pass a data table to writetoserver which inserts the data.
4) Following this to work the pass the value to data table in the order which is in the corresponding table. Because based on that only the data will be inserted. Passing the values in data table wrongly, might save the values wrongly in table.
No responses found. Be the first to comment...