DreamweaverMX Ultradev Exploration (3-2)
Author:Eve Cole
Update Time:2009-05-31 21:07:40
Dreamweaver MX Ultradev exploration (3) Add records to the database
<4> Our highlight is here. This is when you really feel the power of DW MX. You can achieve many seemingly difficult effects without writing a line of code. Application--->Server Behaviors--->Insert Record, as shown in Figure (3-7).
3-7
DW MX comes with many practical server behaviors, such as data insertion, update, deletion, etc. Here we will temporarily introduce data insertion, and we will talk about other behaviors later. Click it, and a dialog box for inserting data will appear, as shown in Figure (3-8). This dialog box allows you to build your own database using form elements available on the page. The fields below need to be filled in.
Connection: You can select the specified database connection in the Connection database drop-down list box. If no connection is specified, click the Define button to define the database connection. Here we select the database testmx we just specified above.
Insert Into Table: This will be a drop down list of all tables in the database. Here we select the data table "User Table" we just created.
After Inserting, Go To: This allows the user to be redirected to another page after the insertion is completed, that is, the page displayed to the user after the data is successfully saved into the database, telling the user that the data has been inserted into the database. Here we define it as insertok.asp. Note: Don’t forget to create this page. If the page cannot be found, an error will be reported!
Get Values From: Set this field to form1. It should be the only form on the page; but if there are multiple forms, it's possible to make use of a drop-down list of the forms.
Form Elements: Text fields should all be listed here. All of these items must be set one by one, including selecting the form element, selecting the appropriate data column, and the appropriate data type below the text box. The username will be inserted into the "Username" column, the password will be inserted into the "Password" column, and the email address will be inserted into the "Mailbox" column. Just now we defined the name of the text box and the field name of the database to be the same, so DW MX will automatically match them. We should try to make the form name and the database field name the same in the future. This is a good habit.
Column and Submit As: The data type of the text box when it is submitted. Generally, we do not need to select it, DW MX will automatically make the selection.
3-8
<5> After completing these steps, you can click the OK button and the Server Behavior will be applied to this page. Server Behavior will automatically write all the code to the page and complete the database insertion. As shown in Figure (3-9). DW MX will use different colors to indicate that a server behavior is used.
3-9
Finally, test it out! As shown in Figure (3-10).
3-10
<6> Submit, and then open the database we just designed, as shown in Figure (3-11), the content we just submitted is lying in it, haha. . . Dreamweaver MX makes our world more beautiful.
3-11
In the next chapter, we will talk about how to update the data in the database. DW MX has more exciting features waiting for us to use.