IDataRecord

IDataRecord

System.Data (system.data.dll) interface

This interface provides access to column values when you use a data reader. You can retrieve a value from a column using the indexer for IDataRecord with the column name or index. Alternatively, you can use one of the typed accessor methods to retrieve a column value by index and convert it to the specified type in one step. For example, GetInt32( ) retrieves the specified column value and casts it to the System.Int32 type. Provider-specific data readers add methods that return data using source-specific data types. You can use the FieldCount property to determine how many columns are in a table. However, if you aren't positioned on a record (for example, you havn't called IDataReader.Read( ) ), this property returns 0.

 public interface  IDataRecord  {  // Public Instance Properties  public int  FieldCount  {get; } 
   public object  this[string    name    ]  {get; } 
   public object  this[int    i    ]  {get; }  // Public Instance Methods  public bool  GetBoolean  ( int   i   );  
   public byte  GetByte  ( int   i   );  
   public long  GetBytes  (int   i   , long   fieldOffset   , byte[ ]   buffer   , int   bufferoffset   , int   length   );
   public char  GetChar  ( int   i   );  
   public long  GetChars  (int   i   , long   fieldoffset   , char[ ]   buffer   , int   bufferoffset   , int   length   );
   public IDataReader  GetData  ( int   i   );  
   public string  GetDataTypeName  ( int   i   );  
   public DateTime  GetDateTime  ( int   i   );  
   public decimal  GetDecimal  ( int   i   );  
   public double  GetDouble  ( int   i   );  
   public Type  GetFieldType  ( int   i   );  
   public float  GetFloat  ( int   i   );  
   public Guid  GetGuid  ( int   i   );  
   public short  GetInt16  ( int   i   );  
   public int  GetInt32  ( int   i   );  
   public long  GetInt64  ( int   i   );  
   public string  GetName  ( int   i   );  
   public int  GetOrdinal  ( string   name   );  
   public string  GetString  ( int   i   );  
   public object  GetValue  ( int   i   );  
   public int  GetValues  ( object[ ]   values   );  
   public bool  IsDBNull  ( int   i   );  
} 

Implemented By

IDataReader , System.Data.Common.DbDataRecord , System.Data.OleDb.OleDbDataReader , System.Data.OracleClient.OracleDataReader , System.Data.SqlClient.SqlDataReader

IDbCommand diposable

System.Data (system.data.dll) interface

The IDbCommand interface represents a command that can be executed against a data source. Some examples include queries that retrieve rows (a SQL SELECT statement), statements that retrieve a single piece of information (such as SQL aggregate functions), or statements designed to modify rows (such as a SQL UPDATE, DELETE, or INSERT statement). ADO.NET providers that access relational data implement this interface.

Before, using the command, you must set the Connection property to a valid IDbConnection and open the connection. You can then execute the command in one of three ways. Use ExecuteNonQuery( ) to execute a statement such as INSERT, DELETE, or UPDATE, which returns the number of rows affected. Use ExecuteScalar( ) to execute a statement that returns a single value, such as an aggregate SQL function (SUM, MAX, MIN, AVG, and so on). Finally, use ExecuteReader( ) to perform a query and return a IDataReader that provides access to the result set. The CommandTimeout property identifies the number of seconds ADO.NET will wait while trying to execute the command before throwing a provider-specific exception. The default is 30, and 0 represents an infinite wait. Finally, if you are using a stored procedure, you can use the Prepare( ) method to compile the stored procedure in the data source, which may improve performance with some providers if you are executing the same stored procedure multiple times with different parameters. (It's recommended that you profile this approach to gauge if it offers any improvement.)

There are three types of commands (as identified by the CommandType property). The default is CommandType.Text , which represents a SQL text statement set in the CommandText property). You can also use CommandType.TableDirect to directly retrieve a single table (if the provider supports it) or CommandType.StoredProcedure to invoke a stored procedure. In either case, you identify the table or stored procedure by name in the CommandText property. For stored procedures that use parameters, you must add a single IDataParameter object for each parameter to the Parameters collection. The order is sometimes important with parameterized queries. See the description for the IDataParameter type for more information. Commands can be enlisted in a client-initiated transaction by setting the Transaction property to an IDbTransaction instance.

The UpdatedRowSource property specifies how command results are applied to the DataRow when a DataSet is reconciled with the data source using the Update( ) method of a DbDataAdapter . The default value, UpdateRowSource.None , does nothing. However, you can use UpdateRowSource.OutputParameters to ensure that the values set in the output parameters of a stored procedure are applied automatically to the changed DataRow when the row update is completed. Alternatively, you can use UpdateRowSource.FirstReturnedRecord to map an entire row returned by a stored procedure to the DataRow . This technique is useful if you are inserting a record that has an identity (or timestamp) value, which was set or changed during the update.

 public interface  IDbCommand  : IDisposable {  // Public Instance Properties  public string  CommandText  {set; get; } 
   public int  CommandTimeout  {set; get; } 
   public CommandType  CommandType  {set; get; } 
   public IDbConnection  Connection  {set; get; } 
   public IDataParameterCollection  Parameters  {get; } 
   public IDbTransaction  Transaction  {set; get; } 
   public UpdateRowSource  UpdatedRowSource  {set; get; }  // Public Instance Methods  public void  Cancel  (  );  
   public IDbDataParameter  CreateParameter  (  );  
   public int  ExecuteNonQuery  (  );  
   public IDataReader  ExecuteReader  (  );  
   public IDataReader  ExecuteReader  (
        CommandBehavior   behavior   );  
   public object  ExecuteScalar  (  );  
   public void  Prepare  (  );  
} 

Implemented By

System.Data.OleDb.OleDbCommand , System.Data.OracleClient.OracleCommand , System.Data.SqlClient.SqlCommand

Returned By

System.Data.Common.RowUpdatedEventArgs.Command , System.Data.Common.RowUpdatingEventArgs.Command , IDbConnection.CreateCommand( ) , IDbDataAdapter.{DeleteCommand , InsertCommand , SelectCommand , UpdateCommand}

Passed To

Multiple types