Chapter 7. The Command Object

The Command object performs one of three tasks. First, it can query the data source and return a Recordset object. By giving the Command object the name of a parameterized query, a stored procedure, or even a table, the Command object can execute instructions and return to your application a Recordset object with the results of the operation. Although we have learned to pass SQL statements and open tables with other objects from ADO (e.g., Recordset objects), as we will soon learn, the Command object is the only object that can use Parameter objects.

Second, the Command object can execute bulk operations such as an UPDATE or INSERT INTO SQL statement. Again, the Recordset object can provide the same functionality, but the Command object will allow the persistence of its command text for re-execution, unlike the Recordset object.

Finally, the Command object can alter the state of the underlying data source using SQL statements. Appendix A, introduces the Structured Query Language (SQL) and provides examples of commands that can alter the structure of a data source.

Get ADO: ActiveX Data Objects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.