CommandBehavior CommandBehavior CommandBehavior CommandBehavior Enum

定义

提供对查询结果和查询对数据库的影响的说明。Provides a description of the results of the query and its effect on the database.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class CommandBehavior
[System.Flags]
public enum CommandBehavior
type CommandBehavior = 
Public Enum CommandBehavior
继承
CommandBehaviorCommandBehaviorCommandBehaviorCommandBehavior
属性

字段

CloseConnection CloseConnection CloseConnection CloseConnection 32

执行命令时,关闭关联的 DataReader 对象时,关联的 Connection 对象也会关闭。When the command is executed, the associated Connection object is closed when the associated DataReader object is closed.

Default Default Default Default 0

查询可能返回多个结果集。The query may return multiple result sets. 执行查询可能会影响数据库状态。Execution of the query may affect the database state. Default 未设置 CommandBehavior 标志,因此调用 ExecuteReader(CommandBehavior.Default) 在功能上等效于调用 ExecuteReader()Default sets no CommandBehavior flags, so calling ExecuteReader(CommandBehavior.Default) is functionally equivalent to calling ExecuteReader().

KeyInfo KeyInfo KeyInfo KeyInfo 4

查询返回列和主键信息。The query returns column and primary key information. 提供程序将额外的列附加到现有主键和时间戳列的结果集。The provider appends extra columns to the result set for existing primary key and timestamp columns.

SchemaOnly SchemaOnly SchemaOnly SchemaOnly 2

查询仅返回列信息。The query returns column information only. 使用 SchemaOnly 时,用于 SQL Server 的 .NET Framework 数据提供程序在要执行的语句前加上 SET FMTONLY ON。When using SchemaOnly, the .NET Framework Data Provider for SQL Server precedes the statement being executed with SET FMTONLY ON.

SequentialAccess SequentialAccess SequentialAccess SequentialAccess 16

提供一种方法,以便 DataReader 处理包含带有大型二进制值的列的行。Provides a way for the DataReader to handle rows that contain columns with large binary values. SequentialAccess 不是加载整行,而是使 DataReader 能够以数据流的加载数据。Rather than loading the entire row, SequentialAccess enables the DataReader to load data as a stream. 然后可以使用 GetBytesGetChars 方法来指定开始读取操作的字节位置,以及正在返回的数据的有限缓冲区大小。You can then use the GetBytes or GetChars method to specify a byte location to start the read operation, and a limited buffer size for the data being returned.

SingleResult SingleResult SingleResult SingleResult 1

查询返回单个结果集。The query returns a single result set.

SingleRow SingleRow SingleRow SingleRow 8

查询应返回结果集中的单行。The query is expected to return a single row of the first result set. 执行查询可能会影响数据库状态。Execution of the query may affect the database state. 某些 .NET Framework 数据提供程序可能(但不要求)使用此信息来优化命令性能。Some .NET Framework data providers may, but are not required to, use this information to optimize the performance of the command. 使用 OleDbCommand 对象的 ExecuteReader() 方法指定 SingleRow 时,用于 OLE DB 的 .NET Framework 数据提供程序使用 OLE DB IRow 接口(如果可用)执行绑定。When you specify SingleRow with the ExecuteReader() method of the OleDbCommand object, the .NET Framework Data Provider for OLE DB performs binding using the OLE DB IRow interface if it is available. 否则,它使用 IRowset 接口。Otherwise, it uses the IRowset interface. 如果期望 SQL 语句仅返回一行,则指定 SingleRow 也可提高应用程序性能。If your SQL statement is expected to return only a single row, specifying SingleRow can also improve application performance. 执行应返回多个结果集的查询时,可指定 SingleRowIt is possible to specify SingleRow when executing queries that are expected to return multiple result sets. 在这种情况下,如果同时指定了多结果集 SQL 查询和单行,返回的结果仅包含第一个结果集的第一行。In that case, where both a multi-result set SQL query and single row are specified, the result returned will contain only the first row of the first result set. 不返回查询的其他结果集。The other result sets of the query will not be returned.

注解

CommandBehavior通过使用值ExecuteReader方法的IDbCommand和任何实现类。The CommandBehavior values are used by the ExecuteReader method of IDbCommand and any implementing classes.

可能使用这些值的按位组合。A bitwise combination of these values may be used.

CommandBehavior 用于定义时,将忽略SqlNotificationRequestSqlDependency并因此不能使用。CommandBehavior is ignored when used to define a SqlNotificationRequest or SqlDependency and should therefore not be used. 使用构造函数不需要CommandBehavior这两种情况中的参数。Use the constructor that does not require a CommandBehavior parameter in these two cases.

有关单独的枚举成员的说明Notes on individual enumeration members

使用时KeyInfo,SQL Server 的.NET Framework 数据提供程序位于与正在执行的语句SET FMTONLY OFFSET NO_BROWSETABLE ONWhen using KeyInfo, the .NET Framework Data Provider for SQL Server precedes the statement being executed with SET FMTONLY OFF and SET NO_BROWSETABLE ON. 用户应注意潜在的负面影响,如使用的干扰SET FMTONLY ON语句。The user should be aware of potential side effects, such as interference with the use of SET FMTONLY ON statements. 有关详细信息,请参阅 SET FMTONLY (Transact-SQL)For more information, see SET FMTONLY (Transact-SQL).

备注

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

当指定SequentialAccess,需要从它们的返回的顺序中的列读取,虽然不需要读取每个列。When you specify SequentialAccess, you are required to read from the columns in the order they are returned, although you are not required to read each column. 位置或该位置之前的数据后已经读过的数据返回的流中的某个位置,不能再从读取DataReaderOnce you have read past a location in the returned stream of data, data at or before that location can no longer be read from the DataReader. 当使用OleDbDataReader,直到读过它,您可以重新读取当前列的值。When using the OleDbDataReader, you can reread the current column value until reading past it. 当使用SqlDataReader,可以一次读取某列的值。When using the SqlDataReader, you can read a column value only once.

适用于