I suppose that's one solution though I was hoping for something a bit more transparent.
To remedy the current situation I simply threw the connection into an instance object and then made a sub called close that closes the instance object if it's not null.
It works well for this kind of situation but I can imagine situations where even this might get hairy.
Main Topics
Browse All Topics





by: naspinskiPosted on 2008-04-26 at 23:02:34ID: 21448305
Can you try passing the connection as well? Then after the reader is consumed, close it in another function?
Just thinking out loud here:
Make this function a void, and at the end, call doSomeStuff(SqlDataReader myReader, SqlConnection conn)
And in doSomeStuff, call whatever is working with the datareader, and hold until its done, then close the connection?
I suppose this could all be done within the function as well, but that coudl get messy.
Do you understand what I am saying?