Using ASP commands to modify a database
You can use Dreamweaver to create ASP command objects that insert, update, or delete records in a database. A command object is a server object that performs some operation on a database. You supply the command object with the SQL statement that performs the operation on the database. For more information, see ASP command objects.
You can also supply the object with a stored procedure that performs the operation. For more information, see Running a stored procedure (ASP).
To create the command object that uses SQL to edit a database:
- In Dreamweaver, open the ASP page that will run the command.
- Open the Server Behaviors panel (Window > Server Behaviors), click the Plus (+) button and select Command.
The Command dialog box appears.
- Enter a name for the command, select a connection to the database containing the records you want to edit, and select the editing operation you want the command to perform--Insert, Update, or Delete.
Dreamweaver starts the SQL statement for you based on the type of operation you select. For example, if you select Insert, the dialog looks as follows:
- Complete the SQL statement.
For information on writing SQL statements that modify databases, consult a Transact-SQL manual.
- Use the Variables area to define any SQL variables.
For example, below is 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.
After you close the dialog box, Dreamweaver inserts ASP code in your page that, when run on the server, creates a command that inserts, updates, or deletes records in the database.
By default, the code sets the Prepared property of the Command object to
true, which makes the application server reuse a single compiled version of the object every time the command is run. To change this setting, switch to Code view and change the Prepared property to
In the above example, next you would probably create a page with an HTML form so users could enter record data. The HTML form would contain three text fields (txtCity, txtAddress, and txtPhone) and a submit button. The form would use the
GET method and submit the text field values to the page containing your command.