SqlCommand.ExecuteReader Method

Definition

Sends the CommandText to the Connection and builds a SqlDataReader.

Overloads

Name Description
ExecuteReader()

Sends the CommandText to the Connection and builds a SqlDataReader.

ExecuteReader(CommandBehavior)

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

ExecuteReader()

Source:
System.Data.SqlClient.notsupported.cs

Sends the CommandText to the Connection and builds a SqlDataReader.

public:
 System::Data::SqlClient::SqlDataReader ^ ExecuteReader();
public System.Data.SqlClient.SqlDataReader ExecuteReader();
override this.ExecuteReader : unit -> System.Data.SqlClient.SqlDataReader
member this.ExecuteReader : unit -> System.Data.SqlClient.SqlDataReader
Public Function ExecuteReader () As SqlDataReader

Returns

A SqlDataReader object.

Exceptions

A SqlDbType other than Binary or VarBinary was used when Value was set to Stream. For more information about streaming, see SqlClient Streaming Support.

-or-

A SqlDbType other than Char, NChar, NVarChar, VarChar, or Xml was used when Value was set to TextReader.

-or-

A SqlDbType other than Xml was used when Value was set to XmlReader.

An exception occurred while executing the command against a locked row. This exception is not generated when you are using Microsoft .NET Framework version 1.0.

-or-

A timeout occurred during a streaming operation. For more information about streaming, see SqlClient Streaming Support.

The current state of the connection is closed. ExecuteReader() requires an open SqlConnection.

-or-

The SqlConnection closed or dropped during a streaming operation. For more information about streaming, see SqlClient Streaming Support.