asp.net.ph

IDbCommand.ExecuteReader Method

System.Data Namespace   IDbCommand Class


Sends the CommandText to the Connection and builds an IDataReader.

Overload List

1. Sends the CommandText to the Connection and builds an IDataReader.

2. Sends the CommandText to the Connection, and builds an IDataReader using one of the CommandBehavior values.


Example

The following example illustrates use of the ExecuteReader method.

NOTE: This example uses one of the overloaded versions of ExecuteReader. For other examples that may be available, see the individual overload topics.

void ExecuteReaderDemo ( string query, string connString ) {
   SqlConnection myConn = new SqlConnection ( connString );
   SqlCommand myCmd = new SqlCommand ( query, myConn );
   myConn.Open ( );
   // bind a datalist to the reader
   myList.DataSource = myCmd.ExecuteReader ( CommandBehavior.CloseConnection );
   myList.DataBind ( );
   myConn.Close ( );
}
  C# VB

Binding a DataReader to a Repeater
Run Sample | View Source
Binding a DataReader to a DataList
Run Sample | View Source
Binding a DataReader to a DataGrid
Run Sample | View Source

See Also

IDbCommand Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph