Name

OleDbCommand

Synopsis

This class represents a SQL command that can be executed against a data source through the .NET OLE DB provider. For information about the basic OleDbCommand methods and properties, refer to the reference for the System.Data.IDbCommand interface, which OleDbCommand implements. OleDbCommand errors result in a OleDbException being thrown.

When CommandType is set to System.Data.CommandType.Text, named parameters aren’t supported. This differs from the SQL Server provider. In this case, you must use a question mark (?) placeholder for parameters in the SQL statement. For example, you can set the CommandType to System.Data.CommandType.Text, and set the CommandText to:

SELECT * FROM Customers WHERE CustomerID = ?

to specify that a CustomerID value will be supplied as a parameter. If there is more than one parameter, the order in which you insert the OleDbParameter to the Parameters collection must match the order of the placeholders.

public sealed class OleDbCommand : System.ComponentModel.Component, ICloneable, System.Data.IDbCommand {

// Public Constructors

   public OleDbCommand( );  

   public OleDbCommand(string cmdText);  

   public OleDbCommand(string cmdText, OleDbConnection connection);

   public OleDbCommand(string cmdText, OleDbConnection connection, OleDbTransaction transaction);

// Public Instance Properties

   public string CommandText{set; get; }                       // implements System.Data.IDbCommand

   public int CommandTimeout{set; get; }                       // implements System.Data.IDbCommand public CommandType ...

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.