IDbCommand.ExecuteReader IDbCommand.ExecuteReader IDbCommand.ExecuteReader IDbCommand.ExecuteReader Method

定义

Connection 执行 CommandText 并生成 IDataReaderExecutes the CommandText against the Connection and builds an IDataReader.

重载

ExecuteReader() ExecuteReader() ExecuteReader() ExecuteReader()

Connection 执行 CommandText 并生成 IDataReaderExecutes the CommandText against the Connection and builds an IDataReader.

ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior)

Connection 执行 CommandText,并使用 CommandBehavior 值之一生成 IDataReaderExecutes the CommandText against the Connection, and builds an IDataReader using one of the CommandBehavior values.

ExecuteReader() ExecuteReader() ExecuteReader() ExecuteReader()

Connection 执行 CommandText 并生成 IDataReaderExecutes the CommandText against the Connection and builds an IDataReader.

public:
 System::Data::IDataReader ^ ExecuteReader();
public System.Data.IDataReader ExecuteReader ();
abstract member ExecuteReader : unit -> System.Data.IDataReader
Public Function ExecuteReader () As IDataReader

返回

ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior) ExecuteReader(CommandBehavior)

Connection 执行 CommandText,并使用 CommandBehavior 值之一生成 IDataReaderExecutes the CommandText against the Connection, and builds an IDataReader using one of the CommandBehavior values.

public:
 System::Data::IDataReader ^ ExecuteReader(System::Data::CommandBehavior behavior);
public System.Data.IDataReader ExecuteReader (System.Data.CommandBehavior behavior);
abstract member ExecuteReader : System.Data.CommandBehavior -> System.Data.IDataReader
Public Function ExecuteReader (behavior As CommandBehavior) As IDataReader

参数

返回

注解

调用方必须调用Open方法的Connection属性。The caller must call the Open method of the Connection property.

CommandType属性设置为StoredProcedure,则CommandText属性应设置为存储过程的名称。When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure. 该命令执行此存储的过程调用时ExecuteReaderThe command executes this stored procedure when you call ExecuteReader.

备注

使用SequentialAccess检索大值和二进制数据。Use SequentialAccess to retrieve large values and binary data. 否则为OutOfMemoryException可能会出现,连接将被关闭。Otherwise, an OutOfMemoryException might occur and the connection will be closed.

虽然IDataReader正在使用中,关联IDbConnection是繁忙的服务IDataReaderWhile the IDataReader is in use, the associated IDbConnection is busy serving the IDataReader. 在此状态下,没有其他操作可以执行上IDbConnection而不关闭它。While in this state, no other operations can be performed on the IDbConnection other than closing it. 这种情况直到Close调用 DataReader 的方法。This is the case until the Close method of the DataReader is called. 如果使用创建 DataReaderCommandBehavior设置为CloseConnection,关闭 DataReader 自动关闭的连接。If the DataReader is created with CommandBehavior set to CloseConnection, closing the DataReader closes the connection automatically.

适用于