|
-
Feb 27th, 2003, 08:54 AM
#1
Thread Starter
Lively Member
when to close the connection and transaction?
hi,
my question is about the right place where I should close a connection and commit/rellback a transaction
a page look like this
...
try
dim conn as sqlclient.sqlconnection(...)
conn.open()
... define a transaction
... do database operations with the connection & transaction
... end of the operations
... commit the transaction
conn.close()
catch ex as exception
...if I try to rolback & close the transaction, it seems that those are not available here
finally
...same (connection seems to not be available here)
end try
did I close the connection in the reght place?
what is happening when something fail: when the connection will be closed, and when I can rollback the transaction?
thank you,
svatasoiu
-
Feb 27th, 2003, 09:31 AM
#2
Hyperactive Member
The conn is being dimmed inside the scope of the try block and as such isn't available within the catch. Don't ask me why but that's what I've observed...
So you should be OK by doing the Dim before the try and you could always do the close in the "finally" while leaving the rollback and and commit in the catch and try.
-
Feb 27th, 2003, 09:42 AM
#3
Thread Starter
Lively Member
thank you for your quick answer.
you are right, I did not realized that by dim-ing in the try block, I restrict the availability of the connection
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|