System.Data.OleDb.OleDbCommand Class

Represents an SQL statement or stored procedure to execute against a data source.

See Also: OleDbCommand Members

Syntax

[System.ComponentModel.DefaultEvent("RecordsAffected")]
[System.ComponentModel.ToolboxItem("System.Drawing.Design.ToolboxItem, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")]
[System.ComponentModel.Designer("Microsoft.VSDesigner.Data.VS.OleDbCommandDesigner, Microsoft.VSDesigner, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public sealed class OleDbCommand : System.Data.Common.DbCommand, ICloneable

Remarks

When an instance of System.Data.OleDb.OleDbCommand is created, the read/write properties are set to their initial values. For a list of these values, see the System.Data.OleDb.OleDbCommand constructor.

System.Data.OleDb.OleDbCommand features the following methods executing commands at a data source:

OleDbCommand.ExecuteReader

Executes commands that return rows. OleDbCommand.ExecuteReader may not have the effect that you want if used to execute commands such as SQL SET statements.

OleDbCommand.ExecuteNonQuery

Executes commands such as SQL INSERT, DELETE, UPDATE, and SET statements.

OleDbCommand.ExecuteScalar

Retrieves a single value, for example, an aggregate value from a database.

You can reset the OleDbCommand.CommandText property and reuse the System.Data.OleDb.OleDbCommand object. However, you must close the System.Data.OleDb.OleDbDataReader before you can execute a new or previous command.

If a fatal System.Data.OleDb.OleDbException (for example, a SQL Server severity level of 20 or greater) is generated by the method executing an System.Data.OleDb.OleDbCommand, the System.Data.OleDb.OleDbConnection, the connection may be closed. However, the user can reopen the connection and continue.

Requirements

Namespace: System.Data.OleDb
Assembly: System.Data (in System.Data.dll)
Assembly Versions: 1.0.3300.0, 1.0.5000.0, 2.0.0.0