The Activex data object(ADO) Command object is used to execute a single query against the database. The query can perform diffrent actions like creating, adding, retrieving, deleting or updating records as per need.
The Command object is used to execute the general commands against the data within the database. These commands can have parameters - For example, the command may be a database insert command: the parameters are then the data elements to insert.
ADO Command object has a Parameters collection made up of Parameter objects.
The feature of the Command object is the ability to use stored queries and procedures with parameters.Parameter and it's discription is given bellow.
ADO Command Object Properties
Property
Description
ActiveConnection
The Connection object to which the specified Command object currently belongs.
CommandText
The text of a command that you want to issue against a provider.
CommandTimeout
How long to wait while executing a command before terminating the command and issuing an error.
CommandType
The type of Command object.
Name
The name of a specific Command object. This property is not currently supported on UNIX.
Prepared
Whether or not to save a compiled version of a command before execution. This property is not currently supported on UNIX.
State
The current state of the Command object. This property is not currently supported on UNIX.
There are thee method of the ADO Command object.These method are given bellow.
Method
Method
Description
Cancel
Cancels an execution of a method
CreateParameter
Creates a new Parameter object.
Execute
Executes the query, SQL statement or procedure in the CommandText property
ADO Command Object with SQL
To execute the query, by using the ADO Command object to set the active connection, define any query parameters such as number of results to display on each page, define the query, execute the query, and create the ADO Recordset object containing the search results.
For Example: Following code given bellow that creates the Command object, sets the Maximum Rows property, and creates and opens the recordset.
<%
set AdoCommand = Server.CreateObject("ADODB.Command.1.5")
set AdoCommand.ActiveConnection = Conn
AdoCommand.Properties("Maximum Rows") = 10
AdoCommand.CommandText = "SELECT vpath, DocTitle FROM Catalog1..Scope() WHERE CONTAINS('chocolate') > 0"
Set RS = Server.CreateObject("ADODB.RecordSet.1.5")
RS.Open AdoCommand
%>
Share And Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.