DreamweaverMX Ultradev Exploration (4-2)
Author:Eve Cole
Update Time:2009-05-31 21:07:35
DreamweaverMX Ultradev exploration (4-2) Modify records in the database
<4> Well, this is good, but how do I know which record to display here? What should I do if it doesn’t match the number clicked by the user? Don’t worry, DW MX has already thought of everything for us, LOOK~! That's Move To Specific Record! Application-->Server Behaviors-->Recordset Paging-->Move To Specific Record, similarly, this is also a server behavior that comes with DW MX. As shown in Figure (4-5).
After clicking, the dialog box shown in Figure (4-6) will appear. The function of Move To Specific Record is to move the record pointer in the current record set to the appropriate position. The specific position is determined by the parameters passed by the URL. It seems difficult to understand, but in fact it is not so scary. Please listen to me in detail. Earlier we used the server behavior of jumping to the details page to pass a URL parameter to the sub-page, so here we have to receive this parameter, and then use this parameter to find the corresponding record in the database so that it can be displayed correctly The database content is on the page, so that there will be no record mismatch.
Move To Record In: Select the currently used record set.
Where Column: Select the field containing URL parameters.
Matches URL parameter: The passed parameter name must be the same as previously defined.
4-6
<5> Earlier we mentioned that the subpage performs two different operations. The first is to display data. What we did above is to prepare for displaying the correct data. Next, we need to bind the fields in the database to the corresponding text boxes. As mentioned in Chapter 2, just drag the mouse. It's that simple. The final picture is shown in (4-7).
4-7 <6> Okay, just the last step is left, come on! Update the contents of the database. Still our old friend Application-->Server Behaviors-->Updata Record. As shown in Figure (4-8). By the same token, this server behavior is also built into DW MX, which shows how powerful it is. :)
4-8
After clicking, a dialog box will appear, and the essence of this chapter is here, as shown in Figure (4-9).
Connection: Select the database to be updated in this drop-down list. If there is no specified connection, click the Define button to define one.
Table To Update: Select the name of the database table to be updated here. Here we want to update the records in the "User Table", so we select the "User Table".
Uniqun Key Column: Unique key column, select the key column (usually the ID field of the record) to identify the record on the database form. If the value is a number, check the Numeric option.
After Updating, Go to: The page that will jump after the data is updated successfully. Here we define it to editok.asp (remember to create this page).
Get Values From: Here select the name of the form that displays the record set on your page. We use the default value Form1.
Form Elements: Almost the same as inserting a record set, defining the database field corresponding to the text box in the form that submits data.
Column: The submitted data type is the same as the one inserted into the record set. Generally, the default is enough. Here we use text type.
4-9
The completed page is displayed as shown in Figure (4-10), and the places where server behaviors are used will be marked with different colors.
4-10 bluff~~~~It’s done now, I’m exhausted. :) Come on, test it out!
This is what was in our original database!
4-11
This is the effect displayed on our main page. Did you notice the "edit"? Here I click on the connection with ID 2.
4-12
The result is as we expected. The page displays the record with ID 2. Pay attention to the comparison between the two pictures. Here I change the email address.
4-13
Let’s open our current database file again. Do you see it? The email address has been changed.
4-14
In the next chapter, we will describe how to delete a record in the database, so stay tuned. Dreamweaver MX makes our world more beautiful.