Most ASP texts will jump right into recordsets once you have established your connection. However, if you learn to use the command object right from the start, you'll find that it makes manipulating recordsets much simpler and gives you more options. First, you must create the command object. You do this with the following piece of code:
'Create Command Object
Dim objCmd 'Declare the command variable
Set objCmd = Server.CreateObject("ADODB.Command")
objCmd.CommandType = adCmdText
Note that you set the command object's ActiveConnection property to your connection object, which you created above. Also note that, in this case, our CommandType is text. This allows us to send SQL commands directly to the database server. If you are using SQL Server as your database, the other command types may prove useful, but for most third party databases, such as Oracle or Informix, you are best off sticking with adCmdText. Also note that adCmdText is a constant. The numeric equivalent is 1. The ADO constants are in a file called adovbs.inc. If you have not already included this file in your current page, locate it(it is installed with ASP - just use the windows Find File command to locate it), copy it to your web directory and rename it adovbsinc.asp. Finally, add this line to the very top of your ASP page:
The reason for renaming it is for security purposes -- malicious users can more easily access a file on your server ending in .inc than one ending in .asp. Although this file is rarely changed and most ASP developers know its contents, it's just good practice not to have any of your code visible to web users.
Now you will be able to use any of the constants found in the rest of this tutorial. Before you can actually use a command object, you need to create a recordset object which references it. So without further ado...
(Update: this isn't entirely true - you can use the Command object without a Recordset to perform database operations that do not return a result set)