ADO.NET
How to open/close a Data Reader?
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Mehul B10 reputationPosted Jun 30, 2006, 10:41 PM EDT
To read Data from datareader try while loop and read data from datareader using dtreader.read() to close data reader use dtreader.close()
Preethi12 reputationPosted Jul 1, 2006, 2:54 AM EDT
Muhammad4 reputationPosted Jul 21, 2006, 6:53 AM EDT
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 .