SqlTransactions

  • Thread starter Thread starter Nick K.
  • Start date Start date
N

Nick K.

I have classes in a data access layer that have methods that open a
SqlConnection, create a SqlCommand object, ExecuteNonQuery, and then close
the SqlConnection.

Now, I need to implement transactions accross several of these method calls.
Can I do that if the SqlConnection is closed at the end of each method? In
other words, must the SqlConnection remain open if the SqlTransaction is to
work?
 
Yes, the SQLConnection must remain open if you want to use the
SqlTransaction object.
 
Yes, the Connection must remain open. You can actually create the
transaction 'through' the connection like this:

dim txn as oledbtransaction = myconnection.begintransaction
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top