Working with Commands 

After establishing a connection to a data source, you can execute commands and return results from the data source using a Command object. You can create a command using the Command constructor, which takes optional arguments of an SQL statement to execute at the data source, a Connection object, and a Transaction object. You can also create a command for a particular connection using the CreateCommand method of the Connection object. The SQL statement of the Command object can be queried and modified using the CommandText property.

Each .NET Framework data provider included with the .NET Framework has a Command object: the .NET Framework Data Provider for OLE DB includes an OleDbCommand object, the .NET Framework Data Provider for SQL Server includes a SqlCommand object, the .NET Framework Data Provider for ODBC includes an OdbcCommand object, and the .NET Framework Data Provider for Oracle includes an OracleCommand object.

In This Section

Executing a Command

Describes the ADO.NET Command object and how to use it to execute queries and commands against a data source.

Using Stored Procedures with a Command

Describes how to use a Command object to call a stored procedure, including information about sending and retrieving parameter values.

Automatically Generating Commands

Describes how to use the CommandBuilder to automatically generate INSERT, UPDATE, and DELETE commands for a DataAdapter that has a single-table SELECT command.

Obtaining a Single Value from a Database

Describes how to return a single value from a database query by using a Command object.



Describes the DbCommand class and all of its members.


Describes the OdbcCommand class and all of its members.


Describes the OleDbCommand class and all of its members.


Describes the OracleCommand class and all of its members.


Describes the SqlCommand class and all of its members.

See Also