I'm getting a SqlConnection does not support parallel transactions.
Exception and when the connection attempts to open two transactions, this is what I am doing. I thought nested transactions were fine (I was using sqlite for prototype).
How do I check if the connection is already in the transaction? I am using a Microsoft SQL Server database file.
After some searching, I found this second. It turns out that you can not make nest transactions in ADO.NET. When you try, you probably start two unrelated transactions, which gives a parallel transaction error.
To see if a connection is currently in the transaction, you can do the following:
var com = yourConnection.CreateCommand (); Com.CommandText = "Choose @@ TRANCOUNT"; Var trancount = com.ExecuteScalar ();
This gives the number of nested transactions.
Note that you can manually perform transactions in the nest, without using the SqlTransaction object. For example:
var com = yourConnection.CreateCommand (); Com.CommandText = "BEGIN Transfer"; Com.ExecuteNonQuery (); Com.CommandText = "BEGIN Transfer"; Com.ExecuteNonQuery (); Com.CommandText = "Include the testlet (name) values ('which');"; Com.ExecuteNonQuery (); Com.CommandText = "Commmittance Transaction"; Com.ExecuteNonQuery (); Com.CommandText = "Rallyback transaction"; Com.ExecuteNonQuery (); Com.CommandText = "Select the number from the test number (*)"; Console.light line ("lines found {0}", com.ExecuteScalar ()); This code prints 0
because the nested transaction was completely canceled.
Comments
Post a Comment