OdbcCommand.ExecuteReader 方法

定义

CommandText 发送到 Connection 并生成一个 OdbcDataReaderSends the CommandText to the Connection and builds an OdbcDataReader.

重载

ExecuteReader()

CommandText 发送到 Connection 并生成一个 OdbcDataReaderSends the CommandText to the Connection and builds an OdbcDataReader.

ExecuteReader(CommandBehavior)

CommandText 发送到 Connection,并使用 CommandBehavior 值之一构造 OdbcDataReaderSends the CommandText to the Connection, and builds an OdbcDataReader using one of the CommandBehavior values.

ExecuteReader()

CommandText 发送到 Connection 并生成一个 OdbcDataReaderSends the CommandText to the Connection and builds an OdbcDataReader.

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

返回

OdbcDataReader

一个 OdbcDataReader 对象。An OdbcDataReader object.

注解

应将属性设置 CommandText 为存储过程的完整 ODBC 调用语法。You should set the CommandText property to the full ODBC call syntax for stored procedures. 当你调用时,该命令将执行此存储过程 ExecuteReaderThe command executes this stored procedure when you call ExecuteReader.

使用时 OdbcDataReader ,关联的 OdbcConnection 正忙于为提供服务 OdbcDataReaderWhile the OdbcDataReader is used, the associated OdbcConnection is busy serving the OdbcDataReader. 在此状态下,不能执行任何其他操作,而 OdbcConnection 只是将其关闭。While in this state, no other operations can be performed on the OdbcConnection other than closing it. 在调用的方法之前,会出现这种情况 Close OdbcDataReaderThis is the case until the Close method of the OdbcDataReader is called.

适用于

ExecuteReader(CommandBehavior)

CommandText 发送到 Connection,并使用 CommandBehavior 值之一构造 OdbcDataReaderSends the CommandText to the Connection, and builds an OdbcDataReader using one of the CommandBehavior values.

public:
 System::Data::Odbc::OdbcDataReader ^ ExecuteReader(System::Data::CommandBehavior behavior);
public System.Data.Odbc.OdbcDataReader ExecuteReader (System.Data.CommandBehavior behavior);
override this.ExecuteReader : System.Data.CommandBehavior -> System.Data.Odbc.OdbcDataReader
member this.ExecuteReader : System.Data.CommandBehavior -> System.Data.Odbc.OdbcDataReader
Public Function ExecuteReader (behavior As CommandBehavior) As OdbcDataReader

参数

behavior
CommandBehavior

System.Data.CommandBehavior 值之一。One of the System.Data.CommandBehavior values.

返回

OdbcDataReader

一个 OdbcDataReader 对象。An OdbcDataReader object.

注解

如果希望 SQL 语句仅返回一行,则将指定 SingleRowCommandBehavior 值可以提高应用程序性能。If you expect your SQL statement to return only a single row, specifying SingleRow as the CommandBehavior value may improve application performance.

应将属性设置 CommandText 为存储过程的完整 ODBC 调用语法。You should set the CommandText property to the full ODBC call syntax for stored procedures. 当你调用时,该命令将执行此存储过程 ExecuteReaderThe command executes this stored procedure when you call ExecuteReader.

OdbcDataReader支持一种特殊模式,该模式允许有效读取较大的二进制值。The OdbcDataReader supports a special mode that enables large binary values to be read efficiently. 有关详细信息,请参阅的 SequentialAccess 设置 CommandBehaviorFor more information, see the SequentialAccess setting for CommandBehavior.

备注

SequentialAccessCommandBehavior 不是限制设置; 它只是表示你将至少具有对的顺序访问 OdbcDataReaderThe SequentialAccess value of CommandBehavior is not a limiting setting; it just means that you will have at least sequential access to the OdbcDataReader. 例如,当您在模式下使用 SQL Server ODBC 驱动程序时 SequentialAccess ,仍可以在 OdbcDataReader 按顺序读取所有其他列后移动到行的第一列。For example, when you use the SQL Server ODBC Driver in SequentialAccess mode, you can still move to the first column of an OdbcDataReader row after having read through all the other columns sequentially.

使用时 OdbcDataReader ,关联的 OdbcConnection 正忙于为提供服务 OdbcDataReaderWhile the OdbcDataReader is used, the associated OdbcConnection is busy serving the OdbcDataReader. 在此状态下,不能执行任何其他操作,而 OdbcConnection 只是将其关闭。While in this state, no other operations can be performed on the OdbcConnection other than closing it. 在调用方法之前,会出现这种情况 OdbcDataReader.CloseThis is the case until you call the OdbcDataReader.Close method. 如果 OdbcDataReader 创建时 CommandBehavior 将设置为 CloseConnection ,则关闭 OdbcDataReader 会自动关闭连接。If the OdbcDataReader is created with CommandBehavior set to CloseConnection, closing the OdbcDataReader closes the connection automatically.

适用于