If I create a SqlConnection
and do not create a SqlTransaction
for it from C# code and then use a SqlCommand
to invoke a stored procedure, what is the transactional behavior of the code in the following two scenarios
BEGIN TRANSACTION
statements BEGIN TRANSACTION
at start and ends with a COMMIT TRANSACTION
. Assume that no errors occur that would cause the transactions to rollback
From what I understand, the stored procedure would be invoked outside a transaction and cause the following behavior:
Please comment if my understanding in scenarios in A and B is correct.
Your understanding of the scenarios of A and B is correct.
People prefer ADO.NET transaction when lot of UI side data interaction is involved and people prefer to tackle it at UI Side. Otherwise you have to pass on all the data to the SQL Side and let it handle it which sometimes becomes a overhead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.