Doubt in DataReader functionality..

  • Thread starter Thread starter Imaya kumar Jagannathan
  • Start date Start date
I

Imaya kumar Jagannathan

HI,

When using a datareader, will the Connection remain until
the datareader is closed or the connection is made
everytime when the 'Read' method is called?

Sample code.

While dr.Read
' Manipulations
....
..
..

End While
dr.Close()

My friend says, here the connection is made each time when
the datareader is 'Read' since, ADO.NET is a disconnected
architecture.. is it so? or how does it really work?
Help me Please...
Thanks !!
Imaya Kumar Jagannathan.
 
Once the connection is opened with a datareader it stays open until you
close the data reader.
Assuming you used the "CloseConnection" enum when you executed the data
reader.
Otherwise you also have to close the connection explicitly.

dr.Read just moves it ahead one row of data at a time.
 
Back
Top