You can use Dreamweaver to
create JSP prepared statements that insert, update, or delete records
in a database. A JSP prepared statement is a reusable server object
that contains a SQL statement. You supply the prepared statement with
the SQL that performs the operation on the database.
- In Dreamweaver, open the
JSP page that will run the command.
- Open the Server Behaviors panel (Window >
Server Behaviors), click the Plus (+) button and select Prepared
(Insert, Update, Delete).
The Prepared (Insert, Update, Delete) dialog box appears.
- Enter a name for the prepared statement, select a connection
to the database containing the records you want to edit, and select
the editing operation you want the prepared statement to perform—Insert,
Update, or Delete.
Dreamweaver starts the SQL statement
for you based on the type of operation you select.
- 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.
In the Param column, enter the name of the SQL parameters
used in the SQL statement. In the Run-Time Value column, enter the
form or URL parameter supplying a value to each SQL parameter. For
example, if the value to be assigned to a SQL parameter is supplied
by a URL parameter called txtCity, enter the following run-time
value:
request.getParameter(“txtCity”)
- Click OK.
After you close the dialog box, the JSP code is inserted
in your page; when the code runs on the server, it creates a prepared
statement that inserts, updates, or deletes records in the database.