SqlCommand.ExecuteReader Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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()
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.