Export (0) Print
Expand All
Expand Minimize
5 out of 6 rated this helpful - Rate this topic

CommandBehavior Enumeration

Provides a description of the results of the query and its effect on the database.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

Namespace:  System.Data
Assembly:  System.Data (in System.Data.dll)
[FlagsAttribute]
public enum CommandBehavior
Member nameDescription
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkDefaultThe query may return multiple result sets. Execution of the query may affect the database state. Default sets no CommandBehavior flags, so calling ExecuteReader(CommandBehavior.Default) is functionally equivalent to calling ExecuteReader().
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkSingleResultThe query returns a single result set.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkSchemaOnlyThe 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.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkKeyInfoThe query returns column and primary key information.

When KeyInfo is used for command execution, the provider will append extra columns to the result set for existing primary key and timestamp columns.

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. See SQL Server Books Online for more information.

Supported by the .NET Compact FrameworkSupported by the XNA FrameworkSingleRowThe query is expected to return a single row. Execution of the query may affect the database state. Some .NET Framework 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 IRow interface if it is available. Otherwise, it uses the IRowset interface. If your SQL statement is expected to return only a single row, specifying SingleRow can also improve application performance. It is possible to specify SingleRow when executing queries that return multiple result sets. In that case, multiple result sets are still returned, but each result set has a single row.
Supported by the .NET Compact FrameworkSupported by the XNA FrameworkSequentialAccessProvides a way for the DataReader to handle rows that contain columns with large binary values. Rather than loading the entire row, SequentialAccess enables the DataReader to load data as a stream. 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.

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 can only once.

Supported by the .NET Compact FrameworkSupported by the XNA FrameworkCloseConnectionWhen the command is executed, the associated Connection object is closed when the associated DataReader object is closed.

The CommandBehavior values are used by the ExecuteReader method of IDbCommand and any classes derived from it.

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.

NoteNote:

Use SequentialAccess to retrieve large values and binary data. Otherwise, an OutOfMemoryException might occur and the connection will be closed.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.