This article has been excerpted from the book "A Programmer's Guide to ADO.NET in C#".
If you've ever written database applications using ODBC, DAO, or ADO, you must be familiar with the concept of manipulating data through recordsets or executing direct SQL queries. For example, in DAO and ODBC, you can use either the Execute method of a Database object to execute direct SQL commands or use a recordset to manipulate data by navigating through records one by one.
The Command object allows data to directly execute SQL statements such as INSERT, SELECT, UPDATE, and DELETE against a data source for reading, writing, and updating a database. You can also use the Command object to execute stored procedures. The SqlCommand, OleDbCommand, and OdbcCommand Classes represent the Command objects in SQL, OleDb, and ODBC data providers, respectively. All of the data provider-specific command classes implement the IDbCommand interface, which implements basic functionality for these classes. Figure 5-29 shows the relationship between IDbCommand and the data provider-specific command classes.
Figure 5-29. Data Provider-specific classes implementing IDb Command
Table 5-24 lists some of the more implement properties of the Command class for the OleDb data provider. The CommandText listed in this table can contain either a SQL statement or a stored procedure name. The CommandType determines which one of these forms the Command text takes on.
Table 5-24. OleDb Command Properties