C# ADO.NET Command
The Command Object in ADO.NET executes SQL statements and Stored Procedures against the data source specified in the C# Connection Object. The Command Object requires an instance of a C# Connection Object for executing the SQL statements .
In order to retrieve a resultset or execute an SQL statement against a Data Source , first you have to create a Connection Object and open a connection to the Data Source specified in the connection string. Next step is to assign the open connection to the connection property of the Command Object . Then the Command Object can execute the SQL statements. After the execution of the SQl statement, the Command Object will return a result set . We can retrieve the result set using a Data Reader .
The Command Object has a property called CommandText , which contains a String value that represents the command that will be executed against the Data Source. When the CommandType property is set to StoredProcedure, the CommandText property should be set to the name of the stored procedure.
Click the following links to see some important built in methods uses in the Command Object to execute the SQL statements.