SQLConfiguration SQLConfiguration

Data Access  «Prev  Next»
Lesson 3Creating a command object
Objective Create a command object to query a database.
A command object represents a SQL command that can be executed on a database. Commands are most often a query or database update, but can also execute a stored procedure.
A command object requires a database connection. For the VirtualBookShelf.com project, a connection to the VirtualBookShelf database has already been established in the data environment.
In this lesson, a command object will be added to the data environment. Then a Recordset DTC will be added to the Specials.asp page, and will be associated with the new command object.
stored procedure: A database object, such as a query that can be executed.

Creating a command object

The following simulation shows you how to create a command object called BookRecordsCmd.
Creating Command - Object
By itself, the command object does not do much. Command objects are usually used to execute database queries using the object's execute method, which returns a recordset object as the query result. Therefore, to get access to the result, you associate the command object with a recordset object. You can do this easily in PHP using the Recordset Design Time Control.
In the next lesson, you will learn how to add a recordset Design Time Control object to the VirtualBookShelf Web site.