- Single update / insert / delete operation into database;
- Multiple update / insert / delete operation into database;
- Bulk Copy operation with transaction.
The C# Method Code using SqlBulkCopy
public void InsertUsingSqlBulkCopy(DataTable tableToUpdate, string tableName, ref string err) { using (SqlBulkCopy bulkCopy = new SqlBulkCopy(Configuration.LocalDatabaseConnectionString)) { bulkCopy.DestinationTableName = "dbo." + tableName; try { // Write from the source to the destination. bulkCopy.WriteToServer(tableToUpdate); } catch (SqlException sqlEx) { err = sqlEx.Message; //static class to log the error logging.writeLog(1, err, MethodBase.GetCurrentMethod().DeclaringType.Name); } } }
By Mohd Zulkamal
NOTE : – If You have Found this post Helpful, I will appreciate if you can Share it on Facebook, Twitter and Other Social Media Sites. Thanks =)
0 comments:
Post a Comment