


Read properly the documentation, from the link which I gave you: Within an existing transaction, or be enlisted in a SqlBulkCopy-managed transaction, perform the bulk copy operation Or part of the bulk copy when an error occurs, you can use a No here is text from SqlBulkCopy documentation in msdn Using (SqlBulkCopy bulkCopy = new SqlBulkCopy(con, SqlBulkCopyOptions.Default, tr))

Using (SqlTransaction tr = con.BeginTransaction(IsolationLevel.Serializable)) So is it necessary to do: public void testBulkInsert(string connection, string table, DataTable dt) The bulk copy operation creates, and then commits or rolls back the SqlConnection object without an active transaction. Of SqlBulkCopy with a connection string, or use an existing Want to perform a dedicated bulk copy operation, create a new instance The bulk copy operation occurs in a non-transacted way,īy default, a bulk copy operation is its own transaction. I find the docs a bit unclear on this matter as they initially state thatīy default, a bulk copy operation is performed as an isolated Using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connection)) Or if I call SqlBulkCopy's constructor that takes a string, is that a better way of getting it to occur in a transaction? public void testBulkInsert(string connection, string table, DataTable dt) is it necessary for me to explicitly call con.BeginTransaction Will this automatically be wrapped in a SQL transaction so that if something goes wrong half way through the DB will be left in the same state as it was before the bulk insert began? Or will half the data be inserted? Using (SqlBulkCopy bulkCopy = new SqlBulkCopy(con)) Using (SqlConnection con = new SqlConnection(connection)) I am inserting data via SqlBulkCopy like so: public void testBulkInsert(string connection, string table, DataTable dt)
