CreateCommand

Description

Creates a named object that represents a SQL statement.

Applies to

PSConnectionClass objects

Syntax

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

Returns

PSCommandClass object

Usage

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 returns a command object that can be used to execute the SQL statement that you pass as an argument.

Examples

Example 1

The following code creates a SQL command object named mycommand and executes the SQL statement associated with the command:

PSCommandClass mycommand;
mycommand = myconnect.CreateCommand("SELECT * FROM 
		products");
mycommand.Execute();