Question : What happens if I you close a connection without commiting an open transaction?

I've never had problems with this myself, I think my VBA code is written to properly close a transaction in the event of an error, but I'm curious...

If I close a connection that has an open transaction, is the transaction and it's associated locks released as well? In particular I'm thinking of what would happen with the following...
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Public Sub TesterSub

Dim cn as ADODB.Connection
Set cn = new ADODB.Connection
cn.open connectionstring

cn.begintrans

     cn.execute("UPDATE tblUsers SET UserName = 'John' WHERE ID = 1")

cn.close
set cn = nothing

End Sub

Answer : What happens if I you close a connection without commiting an open transaction?

>If I close a connection that has an open transaction, is the transaction and it's associated locks released as well?
yes. rollback + locks are released
Random Solutions  
 
programming4us programming4us