CommandBehavior Enum
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.
Provides a description of the results of the query and its effect on the database.
This enumeration supports a bitwise combination of its member values.
public enum class CommandBehavior
[System.Flags]
public enum CommandBehavior
[<System.Flags>]
type CommandBehavior =
Public Enum CommandBehavior
- Inheritance
- Attributes
Fields
CloseConnection | 32 | When the command is executed, the associated |
Default | 0 | The query may return multiple result sets. Execution of the query may affect the database state. |
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 | 2 | The query returns column information only. When using SchemaOnly, the .NET Framework Data Provider for SQL Server precedes the statement being executed with SET FMTONLY ON. |
SequentialAccess | 16 | Provides a way for the |
SingleResult | 1 | The query returns a single result set. |
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. Some .NET data providers may, but are not required to, use this information to optimize the performance of the command. 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 |
Remarks
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
is ignored when used to define a SqlNotificationRequest or SqlDependency and should therefore not be used. Use the constructor that does not require a CommandBehavior
parameter in these two cases.
Notes on individual enumeration members
When using KeyInfo
, the .NET Framework Data Provider for SQL Server precedes the statement being executed with SET FMTONLY OFF
and SET NO_BROWSETABLE ON
. The user should be aware of potential side effects, such as interference with the use of SET FMTONLY ON
statements. For more information, see SET FMTONLY (Transact-SQL).
Note
Use SequentialAccess
to retrieve large values and binary data. Otherwise, an OutOfMemoryException might occur and the connection will be closed.
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. Once 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
. When using the OleDbDataReader, you can reread the current column value until reading past it. When using the SqlDataReader, you can read a column value only once.
Applies to
Feedback
Submit and view feedback for