Dreamweaver MX Ultradev Exploration (5-1)
Author:Eve Cole
Update Time:2009-05-31 21:07:32
Dreamweaver MX Ultradev exploration (5) delete records in the database
Continuing our Dreamweaver MX journey, in the previous chapter we learned how to use the server behavior that comes with DW MX to update records in the database. You should still remember this. Its powerful server behavior allows us to operate the database in the database without writing a line of code, such as the previously mentioned inserts, updates, deletes, etc. In this chapter, we will learn how to use DW MX to delete records in the database.
Let’s talk about its basic concept first. :) WEB applications may contain pages that allow users to delete database records through the browser. Usually, the records to be deleted are displayed on the page first, and then unnecessary records are deleted through user operations on the database. DW MX comes with a Delete Record server behavior to operate the database deletion. In fact, it is very similar to the update database operation we learned in the previous chapter. First, browse the data, select the data to be deleted, and then delete the corresponding pages to confirm the deletion. The specific steps are not detailed here, please refer to the previous chapter.
<1> Preparation work, in the previous chapter we described how to use the Go To Detail Page server behavior to jump to the relevant database record fields. Here is no exception, the final display results are shown in Figures (5-1) and (5-2).
5-1
5-2
The detailed aspects of the above production are not detailed here. Please refer to Chapter 4 for details. :)
<2> Okay, the preliminary work has been prepared. This time our protagonist is the server behavior of Delete Record. Its function is also very simple. As you can see from the name, it is specially used to delete record sets. OK, create our sub-page, receive the value passed from the first page, and display the corresponding database record. We also talked about these in Chapter 4, and the final display results are shown in Figures (5-3) and (5-4). Remember to put the table into a form and name the text boxes inside.
5-3
5-4
<3> Detailed introduction of Delete Record. Application-->Server Behaviors-->Delete Record, as shown in Figure (5-5).
5-5
Click to display the dialog box shown in Figure (5-6). It is not difficult to find that it is very similar to the server behavior of updating database content we talked about in the previous chapter.
connection: You can select the database connection to be used from this drop-down list. If there is not one, you can click Define to redefine a database connection.
Delete From Table: In this drop-down list, you can select the records of which table in the database you want to delete.
Select Record From: Select the record set name to use here.
Unique Key Column: Select the key field of the table where the record set is located to be deleted. If the key field content is a number, you need to select the Numeric checkbox on the right. Generally, we can use its default here.
Delete By Submitting: In this drop-down list, select the name of the form to submit the delete operation. Because there is only one form on our page and it is not named, it will automatically select form1. If the form name is changed or there are multiple forms, the corresponding form must be selected.
After Deleting, Go To: Which page to jump to after completing this deletion operation, here we enter delok.asp. (Don’t forget to create this page!)
5-6
After completing this operation, the page display effect is as shown in Figure (5-7). The places where the server behavior is applied will be marked with different colors.
5-7
<4> Final test!
Let us first take a look at the records in the database, as shown in Figure (5-8).
5-8
Sample renderings of the main page (5-9).
5-9
Here we choose to delete the first record, click Delete on the record with ID 1, and it will jump to the deleted sub-page, as shown in Figure (5-10).
5-10
After submission, it will jump to the delok.asp page we just defined above, and then look at the records in the database, as shown in Figure (5-11).
5-11
Oh. . . Everyone should also see that the record has been deleted.