The command object classes (OleDbCommand, SqlCommand, OdbcCommand, and OracleCommand) define database commands. The command can be a SQL query, or some non-query statement such as an INSERT, UPDATE, DELETE, or CREATE TABLE statement.
The object’s Connection property gives the database connection object on which it will execute its command. CommandText gives the SQL text that the command represents.
The CommandType property tells the database the type of command text the command holds. This can be StoredProcedure (CommandText is the name of a stored procedure), TableDirect (CommandText is the name of one or more tables from which the database should return data), or Text (CommandText is a SQL statement).
The command object’s Parameters collection contains parameter objects that define any values needed to execute the command text.
Example program CommandInsert, which is available for download on the book’s website, uses the following code to create an OleDbCommand object that executes the bolded SQL statement INSERT INTO PeopleNames (FirstName, LastName) VALUES (?, ?). The question marks are placeholders for parameters that will be added later. The code then adds two new OleDbParameter objects to the command’s Parameters collection. When the code invokes the command’s ExecuteNonQuery method, the adapter replaces the question marks with these parameter values in the order in which they appear in the Parameters collection. In this example, the value of txtFirstName.Text ...