B
Bobby Smith
Folks,
This is probably a question of best practice.
In many places in my code, i've started a transaction (using the
BeginTransaction() function on my connection object).
I then create a DataReader and start going through my while
(myDataReader.Read()) loop.
Inside of this loop, i need to execute more SQL statements.
I cannot do this on the same connection, because the DataReader is still
open, correct?
But then, to keep my transaction processing, i'd have to create a new
transaction on the new connection, and handle that separately from the
transaction i already created, correct?
And, the sql statements executed on the new connection (and in the new
transaction) would not reflect any data changes that had occurred on the
original connection/transaction, correct?
What is my best practice for handling these situations? Should i just be
doing my transaction starts/ends and connection open/closes in different
places so as to avoid this situation? Or is there something i'm completely
missing?
Any advice would be helpful,
Thanks in advance!
This is probably a question of best practice.
In many places in my code, i've started a transaction (using the
BeginTransaction() function on my connection object).
I then create a DataReader and start going through my while
(myDataReader.Read()) loop.
Inside of this loop, i need to execute more SQL statements.
I cannot do this on the same connection, because the DataReader is still
open, correct?
But then, to keep my transaction processing, i'd have to create a new
transaction on the new connection, and handle that separately from the
transaction i already created, correct?
And, the sql statements executed on the new connection (and in the new
transaction) would not reflect any data changes that had occurred on the
original connection/transaction, correct?
What is my best practice for handling these situations? Should i just be
doing my transaction starts/ends and connection open/closes in different
places so as to avoid this situation? Or is there something i'm completely
missing?
Any advice would be helpful,
Thanks in advance!