DreamweaverMX Ultradev Exploration (4-1)
Author:Eve Cole
Update Time:2009-05-31 21:07:37
Dreamweaver MX Ultradev exploration (4) Modify records in the database
In the previous chapter we talked about how to add new content to the database. But I wonder if you have noticed such a situation. What if I find an error in a database record after submitting it? what to do? Of course it needs to be modified. For this modification, we will modify the contents of the database through WEB. It doesn't sound like it's easy. It doesn't matter, through the introduction in the previous chapters, you should find that calling the database in DW MX is very simple, as long as you click a few mouse clicks. Oh. . . The same goes for updating the contents of the database this time. It’s very simple. Let’s go!~~!
Okay, let us all understand the basic concept of updating database content. Let’s use an analogy first. For example, the user information update in the 5D forum uses database content update. This type of page is usually the main page (the previous page) - the sub-page (the next page). The main page allows the user to choose to record updates (personal information in the 5D forum allows users to choose to record updates), and then passes a parameter to the subpage, and the subpage performs two different operations at the same time. First, it displays existing data so that it can be modified by the user, and then, it updates the modified database contents.
<1> First, we create a record set, as mentioned in Chapter 2, and then use repeated field behavior to create multi-line records. I will not repeat these steps here. The actual rendering is shown in (4.1).
4-1
<2> Did you notice the "edit" above? This is the protagonist of our first step - jump to the detail page link (Go To Detail Page). As mentioned earlier, a parameter is submitted to the subpage on the main page. The "edit" we have here plays this role. When it is clicked, a parameter will be passed to the next page. We first use the mouse to select the word "Edit", and then Application-->Server Behaviors-->Go To Detail Page. This is also a server behavior that comes with DW MX, as shown in Figure (4-2).
4-2
After clicking the mouse, a dialogue interface will appear, as shown in Figure (4-3).
Link: You can select the connection on which this server behavior should be applied in this drop-down list. If you select dynamic content in the document, the content will be automatically selected.
Detail Page: Enter the URL address of the ASP page corresponding to the detail page in this text box, or click the Browser button to select it. Here we enter edit.asp.
Pass URL Parameter: In this text box, enter the parameter name to be passed to the details page through the URL. Remember to enter something that is easy to remember. We will use it later.
Recordset: Select the recordset to which the parameters passed through the URL belong. Which record set does it mean to pass the parameters from? Here select the record set named testmx we just created.
Column: Select the field name in the record set to which the parameter passed by the URL belongs, that is, set the source of the value of the parameter passed by the URL. Here we choose ID, you can also choose something else, but remember to change it to the right one later.
URL Parameters: Indicates that the form values in the main page are passed to the sub-page as URL parameters. We don't use forms on our main page, so we don't need to select them.
Form Parameters: Indicates that the form values in the main page are passed to the sub-page in the form of URL parameters. On the sub-page, you can read the parameters passed here through request.form. Same as above, there is no form, so I don’t select it. (Note: request.form is a basic built-in object in ASP. For detailed methods, please refer to relevant information.)
When the OK button is clicked, the "Edit" we originally selected will become a hypertext link containing dynamic content.
4-3
<3> So far, the preparations for parameter passing on our main page have been completed. What’s left? Naturally, it is also the highlight of this chapter - updating the database content. Create a new page, define it as ASP, the script is VBSscript, and save it as edit.asp, which is what we entered above. Don't make the wrong input, otherwise you will make another mistake. The next thing is to create a record set with the same main page, and then create a form to facilitate users to input update records. The specific display is shown in Figure (4-4).
As mentioned in Chapter 3, also remember to set the name of the text box in the form to be consistent with the name in the database.
4-4