Hi,
What is main work of DataReader class in .NET?
Thanks
Loading
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
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 4, 2012, 7:22 PM EST
DataReader: Reads a forward-only, read-only stream of data from a data source.
Thanks
Jignesh TrivediRank #16 · 50.3K reputationPosted Jan 10, 2012, 8:49 PM EST
DataReader Object in ADO.NET is a stream-based , forward-only, read-only retrieval of query results from the Data Sources , which do not update the data. The DataReader cannot be created directly from code, they can created only by calling the ExecuteReader method of a Command Object.
The DataReader Object provides a connection oriented data access to the Data Sources. A Connection Object can contain only one DataReader at a time and the connection in the DataReader remains open, also it cannot be used for any other purpose while data is being accessed. When we started to read from a DataReader it should always be open and positioned prior to the first record. The Read() method in the DataReader is used to read the rows from DataReader and it always moves forward to a new valid row, if any row exist .
DataReader.Raed();
Usually we are using two types of DataReader in ADO.NET. They are SqlDataReader and the OleDbDataReader . The System.Data.SqlClient and System.Data.OleDb are containing these DataReaders respectively. From the following link you can see in details about these classes in C#.
also refer :http://msdn.microsoft.com/en-us/library/haa3afyz.aspx
hope this help.
Datta KharadRank #2,135 · 668 reputationPosted Jan 11, 2012, 12:43 AM EST
Refer our useful articles:-
http://www.c-sharpcorner.com/uploadfile/61b832/datareader-vs-dataset/
http://www.c-sharpcorner.com/uploadfile/mahesh/datareader-in-ado-net/