Operation Manual

Table Of Contents
679
Building applications visually
Last updated 11/30/2015
A command object can be reusable, in the sense that the application server can reuse a single compiled version of the
object to execute the command a number of times. You make a command reusable by setting the Prepared property of
the Command object to true, as in the following VBScript statement:
mycommand.Prepared = true
If you know the command will be executed more than a few times, having a single compiled version of the object can
make database operations more efficient.
Note: Not all database providers support prepared commands. If your database does not support it, it might return an error
when you set this property to true. It might even ignore the request to prepare the command and set the Prepared property
to false.
A command object is created by scripts on an ASP page, but Dreamweaver lets you create command objects without
writing a line of ASP code.
Use ASP commands to modify a database
You can use Dreamweaver to create ASP command objects that insert, update, or delete records in a database. You
supply the command object with the SQL statement or stored procedure that performs the operation on the database.
1 In Dreamweaver, open the ASP page that will run the command.
2 Open the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button, and select Command.
3 Enter a name for the command, select a connection to the database that contains the records you want to edit, and
select the editing operation that you want the command to perform—Insert, Update, or Delete.
Dreamweaver starts the SQL statement, based on the type of operation you select. For example, if you select Insert,
the dialog box looks like the following example:
4 Complete the SQL statement.
For information on writing SQL statements that modify databases, consult a Transact-SQL manual.
5 Use the Variables area to define any SQL variables. Provide the name and run-time value. Specifying the type and
size of each variable prevents injection attacks.
The following example shows an Insert statement that contains three SQL variables. The values of these variables
are provided by URL parameters passed to the page, as defined in the Run-Time Value column of the Variables area.