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
 
Back
Top