Is SqlDataAdapter.Fill () in SqlTransaction bad practice?

Since I have a “DB util” class with a method DataSet QueryDB(string spName, DBInputParams inputParams)that I use for all my calls in the database, I would like to reuse this method to support transactional calls.

So in the end I will have SqlDataAdapter.Fill in SqlTransaction. Would this be bad practice? Because rarely I see the use of DataAdapter.Fill in a transaction and more often ExecuteReader (). Is there a catch?

Edit1: The thing is, inside my transaction it is often required to get also some data (for example, auto-identifiers) ... so I would like to get it as a DataSet.

Edit2: It's strange when I use this approach in a for (10000) loop from two different processes, I get: "Transaction (Process ID 55) has reached a deadlock on locking resources with another process and has been selected as a victim of the deadlock. Restart the transaction ". Is that the right behavior?

Edit3: (answer for Edit2) I used IDENT_CURRENT('XTable')that was the source of the error. After I returned to SCOPE_IDENTITY(), everything was decided.

+1
source share
2 answers

. , , . SELECT ( SELECT, Fill) , , .

, , SELECT , ? (READ COMMITTED ) . . ( , ) , , , .

, SELECT ( ), ( ), . SELECT , , !

, . , , : System.Transactions. ADO.Net , TransactionScope. , Foo TransactionScope, , Bar ADO.Net, , Foo, Bar . TransactionScope , ADO.Net, Bar, . , ADO.Net, Oracle provider. , : TransactionScope() : TransactionScope , , , TransactionOptions ReadCommitted. TransactionScope , , : , , MSDTC, . , TransactionScope , , IDbTransaction.
+2

, , , //, , . . sql .

, , , .

+2

All Articles