Page

14.1.0- The Command Object

Created by Brendan Doss.
Last Updated by Jim Minatel.  

PublicCategorized as 14. Advanced Data Handling Techniques.

Not yet tagged
<< 14.0.0- Advanced Data Handling TechniquesChapter1414.1.1- Using the Command Object >>

The Command Object

In the examples we've seen so far in Chapters 12 and 13 , we've been using the ADO Connection and Recordset objects to make a connection between our ASP page and our data store, and then to retrieve data from the data store for use in the page. In those examples, every request for data was effectively given by executing a command against the data store.

When we use the phrase 'executing a command against the data store', we mean that we're instructing the data store that we want to perform some task with its data. So far, all our examples have used the same type of command – each time, we've been telling the data store that we wish to select certain data (and have that data returned to the page within a recordset). For example, when we specified the appropriate criteria within the parameters of the Recordset object's Open method, we were selecting which data we wanted to see within our recordset:

 

objRS.Open = "AllMovies", strConnect, adOpenforwardOnly, adLockReadOnly, adCmdTable

 

So, although we didn't mention it at the time, in Chapters 12 and 13 we were executing commands against the data store. There are other types of command too: for example, we might use a command to tell the data store to insert a new record, or to update the contents of a record, or to delete an existing record.

 

Although we can use the Connection and Recordset objects to execute such commands, ADO also provides an object called the Command object, which is specially designed for the purpose of specifying and running commands against the data store.

 

In terms of managing and executing commands, we can get much greater flexibility and functionality from the Command object, because it allows us to run much more complex queries – enabling us to make the most of things like stored procedures and parameters, as we'll see later. But before we leap into such lofty topics, we'll do two things:

 

  • First, we'll warm to the Command object by having a look at how it's used in its simplest form
  • Then, we'll have a look at how to use a query language called SQL to write commands
<< 14.0.0- Advanced Data Handling TechniquesChapter1414.1.1- Using the Command Object >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |