Name

CommandBehavior

Synopsis

This enumeration is used with an overload of the IDbCommand.ExecuteReader( ) method. Typically, you don’t use this method directly but will instead use the IDbCommand.ExecuteReader( ) method that requires no arguments, which is functionally equivalent to calling IDbCommand.ExecuteReader( ) with Default. One notable exception is when you access BLOB information (a column that contains a binary large object). In this case, the SequentialAccess value is useful because it instructs .NET not to load the entire row into memory at once. Rather, the row is read as a stream, and you can use the IDataRecord.GetBytes( ) method (exposed by most DataReader objects) to specify a byte location to start the read operation and the number of bytes to read for the data returned. This technique is demonstrated in Chapter 5. You can also use other CommandBehavior enumeration values to specify the command to return a single value, a single row, column schema information, or column and primary key information.

public enum CommandBehavior {

   Default = 0x00000000,

   SingleResult = 0x00000001,

   SchemaOnly = 0x00000002,

   KeyInfo = 0x00000004,

   SingleRow = 0x00000008,

   SequentialAccess = 0x00000010,

   CloseConnection = 0x00000020

}
System.Data’s components and miscellaneous types
Figure 34-3. System.Data’s components and miscellaneous types

Hierarchy

System.Object System.ValueType System.Enum(System.IComparable, System.IFormattable, System.IConvertible) ...

Get ADO.NET in a Nutshell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.