asp.net.ph

SqlCommand.ExecuteReader Method ( CommandBehavior )

System.Data.SqlClient Namespace   SqlCommand Class


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

[ VB ]
Overloads Public Function ExecuteReader ( _
   ByVal behavior As CommandBehavior _
) As SqlDataReader

[ C# ]
public SqlDataReader ExecuteReader (
   CommandBehavior behavior
);

[ C++ ]
public: SqlDataReader* ExecuteReader (
   CommandBehavior behavior
);

[ JScript ]
public function ExecuteReader (
   behavior : CommandBehavior
) : SqlDataReader;

Parameters

behavior
One of the CommandBehavior values.

Return Value

An SqlDataReader object.

Exceptions


Exception Type Condition
InvalidOperationException Occurs when executing a command within a transaction context that differs from the context in which the connection was originally enlisted.

Remarks

When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. The command executes this stored procedure when you call ExecuteReader.

The SqlDataReader supports a special mode that enables large binary values to be read efficiently. For more information, see the SequentialAccess setting for CommandBehavior.

While the SqlDataReader is in use, the associated SqlConnection is busy serving the SqlDataReader. While in this state, no other operatons can be performed on the SqlConnection other than closing it. This is the case until the Close method of the SqlDataReader is called.

Example

The following examples demonstrate using this version of the ExecuteReader method.

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

See Also

SqlCommand Members   SqlCommand.ExecuteReader Overload List 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