ServerConnection.ExecuteReader Method (String, SqlCommand%)

Executes a reader using a SqlDataReader object value that contains one or more result sets.

Namespace:  Microsoft.SqlServer.Management.Common
Assembly:  Microsoft.SqlServer.ConnectionInfo (in Microsoft.SqlServer.ConnectionInfo.dll)


Public Function ExecuteReader ( _
    sqlCommand As String, _
    <OutAttribute> ByRef command As SqlCommand _
) As SqlDataReader
Dim instance As ServerConnection 
Dim sqlCommand As String 
Dim command As SqlCommand 
Dim returnValue As SqlDataReader 

returnValue = instance.ExecuteReader(sqlCommand, _
public SqlDataReader ExecuteReader(
    string sqlCommand,
    out SqlCommand command
SqlDataReader^ ExecuteReader(
    String^ sqlCommand, 
    [OutAttribute] SqlCommand^% command
member ExecuteReader : 
        sqlCommand:string * 
        command:SqlCommand byref -> SqlDataReader
public function ExecuteReader(
    sqlCommand : String, 
    command : SqlCommand
) : SqlDataReader


  • sqlCommand
    Type: String
    A String value that specifies the Transact-SQL commands to be executed.
  • command
    Type: SqlCommand%
    A SqlCommand object that can be used to cancel the SqlDataReader pipe to terminate a long-running command.

Return Value

Type: SqlDataReader
A SqlDataReader object value that contains one or more result sets.


The SqlDataReader object is returned to let the client process the data without requiring it to read all information into memory.

See Also


ServerConnection Class

ExecuteReader Overload

Microsoft.SqlServer.Management.Common Namespace