ADO.NET
How to open/close a Data Reader?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MuhammadPosted Jul 21, 2006, 10:53 AM
private
static OleDbDataReader olereader ;oleconnection =
new OleDbConnection(sConnection);olecommand1 =
new OleDbCommand("Select * from execution",oleconnection);oleconnection.Open();
//olereader = new OleDbDataReader();olereader = olecommand1.ExecuteReader();
while
(olereader.Read())Console.WriteLine("\t{0}\t{1}\t{2}", olereader.GetString(0), olereader.GetName (1),olereader.FieldCount);
olereader.Close();
oleconnection.Close();
Console.ReadLine();
Hopefully you will have an idea for Retrieving data from datareader .
PreethiPosted Jul 1, 2006, 6:54 AM
Mehul BPosted Jul 1, 2006, 2:41 AM
To read Data from datareader try while loop and read data from datareader using dtreader.read() to close data reader use dtreader.close()