brunk.ac

brunk.ac

  • NA
  • 1
  • 0

SqlDataReader Called From a Component Leave Conn Open?

Aug 13 2004 12:27 PM
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)