I have the following method to bulk the data in the table: First of all, my code populates data in the data table and SX's SQLLockCopy uses this data in the same data by using Clasia.
I need the data to be inserted in all the tables and neither of them I have used the SQL Transaction Class of navit.
The scenario is, more than one threads execute the following code blocks at the same time.
Public Zero Import () {(Using SqlConnection sqlConnection = New SqlConnection (connectionString)) {SqlTransaction sqlTrans = null; Try {sqlConnection.Open (); Sql Trance = sqlConnection.BeginTransaction (Isolation Level SerialJabal) SqlCommand CMD = sqlConnection.CreateCommand (); Cmd.CommandText = "Select Top 1 Tap from Locktable (Excl.)"; CMD. Comma timeout = 3600 * 3; CMD. Transaction = sql trance; SqlDataReader Reader = cmd.ExecuteReader (); Foreign Currency (DT in DataTable DataTab) {ImportIntoDatabase (sqlConnection, dt, sqlTrans); } Reader. Stop it (); SqlTrans.Commit (); } Hold (exception before) {sqlTrans.Rollback (); East; }}} Private Zero Import InDebates (using SQL Connection Connection, Datatelle DT, SKLTRANSPS sqlTrans) {Using SQLBulkCopy BulkPP = New SQLBlockCopy (Escolon, SclubBulkCPip Default, SKLTrans)) {bulkCopy.BulkCopyTimeout = dt.rows.Count * 10; Try {bulkCopy.DestinationTableName = dt.TableName; BulkCopy.WriteToServer (DT); } Hold (Exceptional) {East; To handle this concurrency, I have created a dummy table (table called 'locktable') in the database, where the other table remains (bulk entry table). <3 p> Problem: I am following the exception
: destination table 'can not access Tbl1
: while executing the activity The error has failed to start the transaction again. Description: 3a00000001. The active transaction in this session has been committed or revoked from any other session.
Anyone can help me with this strange behavior of code. I have already searched a lot on the Internet on this issue, but have not found anything useful for me.
In the import (DataTable dt in DataTable) the thread is not going to be safe.
Before importing into sqlConnection is an active reader, so import can not be used in ImportIntoDatabase.
Echo SPP - Why are multi threads if you are locking a table?
If you want to create input while inserting SQL, then use escond method such as SQL Commands.BijenExcect Reader. You get asynch without the upper part of a thread. And datatiles are relatively slow I incorporate using TVP and light weight objects. A major factor in the merger performance is the index fragmentation. If on the order of all the possible insertion order from the order of the clustered index Loop is made simple input, wait for posture, input to input aschi to run asych or input can be read, insert SQL in the same table (s) is not usually going in parallel. My experience has been ordered to insert serial with no difference in time between inserts.
Comments
Post a Comment