Creating a DataReader

 

The DataTable and DataSet classes have a CreateDataReader method that returns the contents of the DataTable or the contents of the DataSet object's Tables collection as one or more read-only, forward-only result sets.

The following console application creates a DataTable instance. The example then passes the filled DataTableto a procedure that calls the CreateDataReader method, which iterates through the results contained within the DataTableReader.

[!CODE [DataWorks DataTable.CreateDataReader#1](../CodeSnippet/VS_Snippets_ADO.NET/DataWorks DataTable.CreateDataReader#1)]

The example displays the following output in the console window:

1 Mary  
2 Andy  
3 Peter  
4 Russ  

CreateDataReader
CreateDataReader
DataTableReaders
ADO.NET Managed Providers and DataSet Developer Center

Show: