Creates a named object that represents a SQL statement.
PSConnectionClass objects
connectionobject.CreateCommand( sql )
Argument |
Description |
---|---|
connectionobject |
A variable that contains a reference to an instance of PSConnectionClass |
sql |
A string that specifies the SQL statement |
PSCommandClass object
CreateCommand allows you to execute the same SQL statement multiple times on a single page. Once you have created the command object, you can execute the command by calling the Execute method.
At runtime, CreateCommand has the following behavior:
Application server |
Runtime behavior |
---|---|
ASP |
Calls the CreateObject method of the Server object to create an ADODB.Command object |
JSP |
Returns a command object that can be used to execute the SQL statement that you pass as an argument |
The following example creates a SQL command object and executes the SQL statement associated with the command:
mycommand = myconnect.CreateCommand("SELECT * FROM products");
mycommand.Execute();
For a JSP target, you must declare “mycommand” as a variable of type PSCommandClass before instantiating it and calling any methods on it.