Using ASP commands to modify a database

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:

  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.

    The Command dialog box appears.

  3. 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:

    This is a picture of the feature being described.

  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.

    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.

    This is a picture of the feature being described.

    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 false.

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.

Getting Started with Dreamweaver
Dreamweaver Basics
Working with Dreamweaver Sites
Laying Out Pages
Adding Content to Pages
Working with Page Code
Preparing to Build Dynamic Sites
Making Pages Dynamic
Developing Applications Rapidly
Building ColdFusion Applications Rapidly
Building ASP.NET Applications Rapidly
Building ASP and JSP Applications Rapidly