2
Answers

SqlDataReader Called From a Component Leave Conn Open?

brunk.ac

brunk.ac

20y
2.3k
1
I was reading an article found here (http://www.c-sharpcorner.com/Code/2003/July/DAC4SQLServerInCSharp.asp) about creating a generic data access component. About 2/3's the way down the page, the author returns a SqlDataReader from a function. When this function is called and the SqlDataReader is returned, wouldn't it leave a connection open? I'm envisioning the usage being DataGrid.DataSource = the SqlDataReader returning function. I can't seem to find a solid answer out there with the necessary info. I have read that the command behaviour will close it for you but in order to trigger the behaviour, wouldn't the SqlDataReader.Close() still have to be called? Your guidance in appreciated, Many thanks in advance, Adam
Answers (2)