Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does SqlConnection.Dispose() perform a rollback on all pending transactions? [duplicate]

Possible Duplicate:
What happens to an uncommitted transaction when the connection is closed?

I know a SqlTransaction will rollback itself on Dispose() (see Will a using statement rollback a database transaction if an error occurs?), but will it be rolled back when its parent SqlConnection is disposed?

like image 584
Juan C. Avatar asked Oct 05 '22 16:10

Juan C.


1 Answers

Yes, but I don't think it is handled by SqlConnection class.

I think it's SQL Server that when the connection is closed automatically roll back all not committed transactions.

Also consider that SqlConnection has a connection pool by default. So it is possible that when you close/dispose a SqlConnection the "real" db connection is still active.

like image 193
Davide Icardi Avatar answered Oct 10 '22 03:10

Davide Icardi