Viewing Data
An efficient means of viewing database information is through an ADO.NET DataReader, which is used to obtain a forward-only, read-only data stream from a database. A DataReader may not be written to or modified. This is a very efficient means of obtaining data when the only action required is to view information. There are three steps to create a DataReader:
1. | Create a command object from the connection object. |
2. | Specify what the command object should do by initializing its CommandText property. |
3. | Create a reader based upon the command object. |
The following example shows how to create an OleDbDataReader, the DataReader belonging to the OLE DB data provider.
OleDbDataReader dbReader = null; OleDbCommand cmd = conn.CreateCommand(); ...
Get C# Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.