In the example of building the development environment, the development environment has been built for the development of network applications, but in order to develop the network database, it is necessary to connect the database well. Starting from this example, we will take the development of e-commerce platform of a toy company as an example to explain the development process of dreamweaver+asp.net+access Network database in detail. This example mainly explains the database connection technology.
Effect description
Create a database connection to Access "Dwconn" by clicking OLE DB Connections in the database panel, as shown in Figure 75-1.
Creative Thinking
The database of e-commerce platform of a toy company consists of DREAMWEAVERCP table, Dreamweavergl table and Dreamweaverkh table. The DREAMWEAVERCP table is used to store the company's product information; The Dreamweavergl table is used to store the relevant information of the company administrator; The Dreamweaverkh table is used to store information about the company's customers. First create the database "Dwdat.mdb" in Access, create 3 datasheets, and then create the database connection in the Dreamweaver site "Dreamweaver100" (the site that you created in the instance build development environment). To facilitate the development of E-commerce platform.
Operation Steps
(1) Copy the "Dwdat.mdb" file and open it with Access. Copy the database file "Dwdat.mdb" under the "CD-ROM source files instance 75" directory to the "C:inetpubwwwrootdat" directory (which is the directory under the site "Dreamweaver100" that is built in instance 1) and open in Access. C:inetpubwwwrootdatdwdat.mdb "file, the database" Dwdat.mdb "includes" DREAMWEAVERCP "," Dreamweavergl "," Dreamweaverkh "," CPDD "and" POL ". L "5 data tables, where the" DREAMWEAVERCP "table is used to store information about the company's products, and its data structure is shown in Figure 75-2; The Dreamweavergl "table is used to manage information about the company's personnel, and its data structure is shown in Figure 75-3;" The Dreamweaverkh table is used to store user registration information for the company, and its data structure is shown in Figure 75-4; CPDD table is used to store product order information for the company, and its data structure is shown in Figure 75-5; The POLL table is used to store the company's online survey data, as shown in Figure 75-6.
(2) New dynamic page. Run Dreamweaver MX 2004, select the File | New menu command, and create a dynamic page named "asp.net VB" in the New Document dialog box that pops up, as shown in Figure 75-7.
Tip: Here is the site set up in instance 2 to develop the toy company network applications, please refer to instance 2 for the establishment of the site.
(3) Create the database connection "Dwconn". Switch to the database panel, click the + button, select OLE DB Connection in the pop-up menu, and create the database connection "Dwconn," as shown in Figure 75-8.
Tip: In step 2, shown in Figure 75-7, you should select OLE DB connection because the database you are connecting to is an Access database, and you should select SQL Server connection when you are connecting to a database that is SQL Servers.
In step 4, shown in Figure 75-7, the Data Link Properties dialog box cannot be opened if there is no reaction when you click the Build button. One reason for this problem may be that MDAC 2.8, XP SP2, and Windows2003 are included by default in the 2.8. Users of XP SP1 who have MDAC 2.8 installed will also be affected by this issue, please refer to HTTP://WWW.MACROMEDIA.COM/CN/SUPPORT/DREAMWEAVER/TS/DOCUMENTS/DW_XP_ for details Sp2.htm#build.
(4) Create a "database connection. UDL". Click Start | "All Programs" | "Accessories" | "Notepad" menu commands, create a blank notepad and name it "database connection. UDL" (the filename is optional, but the suffix of the filename must be ". UDL" instead of ". txt" and the storage location can be set casually), as shown in Figure 75-9 as shown. In this example, you save database connection. UDL on the desktop.
Hint: What is a UDL file? UDL is a universal data connection file through which you can save a connection string. Using a UDL file to store a database connection is very similar to using the ODBC data source name (DSN). UDL files can store OLE DB connection information, such as providers, user names, passwords, and other options.
(5) Select an OLE DB provider. Close the Notepad and double-click Database connections. udl with the left mouse button to open the Data Link Properties dialog box, switch to the provider window, select Microsoft.jet OLE DB 4.0 Provider in the OLE DB provider list, and click Next , as shown in Figure 75-10.
(6) Select and test the connection database. In the Connection tab, select the connection database and test the connection, as shown in Figure 75-11.
(7) Copy the database Connection command. Click the right mouse button, select Open With on the shortcut menu pop-up menu command, open "database connection. UDL" as a Notepad, and copy its database connection commands, as shown in Figure 75-12.
(8) test the database connection. Switch to Dreamweaver, paste the database connection command, and test the database connection, as shown in Figure 75-13.
(9) When testing a database connection, the dialog box shown in Figure 75-14 or the dialog shown in Figure 75-15 shows that the current system does not correctly assign user rights to modify the database.
The solution is as follows:
① opens the C:intepudwwwroot folder, performs the Open | Folder Options menu command, and cancels the check for use simple file sharing in the Folder Options dialog box that pops up, as shown in Figure 75-16.
② Click the right mouse button, select the Properties menu item in the pop-up shortcut menu, and then set the ASP.net Web Admin user right in the Pop-up Dat Properties dialog box, as shown in Figure 75-17.
③ the "Internet Guest account" and "Start IIS process account" permissions are set to allow modification in the DAT Properties dialog box.
(10) If the test succeeds, but when the table item is expanded in the database panel, only the word "none" appears, and the datasheet is not displayed, as shown in Figure 75-18, and is resolved in the following way.
① exit Dreamweaver, double-click the CD source instance Sp2dbfix 1.0.2. MXP to install the extension file.
② run Dreamweaver again and perform the site | advanced | Remove Connection Script menu command.
③ test the database connection again, expand the tables item in the database panel, and expand the data tables.
(11) At this time in the root of the site will be added a new file "Web.config", indicating that it completes the database connection work, the results are shown in Figure 75-1.
Tip: Click the "Build" button in step 4, as shown in Figure 75-8, you can directly open the Data Link Properties dialog box without creating a database connection. UDL and copying its data connection commands, you can set up database-related connections directly in the Data Link Properties dialog box, as shown in Figure 75-10 and figure 75-11 shows.
(12) View the physical path. Because Dreamweaver MX stores the command to connect to the database in the Web.config configuration file, you can see the physical path shown in Figure 75-19 in the centerline box by simply opening the Web.config configuration file and switching to Code view.
(13) Gets the path of the database on the remote host. Because the site will eventually be uploaded to the remote server, its physical path will not normally be the same as the local physical path, and a server variable such as Server.MapPath cannot be used in the Web.config configuration file to obtain the physical path of the database in the remote space. However, there are other ways to get the actual directory physical path of the database on the remote host. First assume that the address of the domain name of the remote space upload is http://www.4u2v.com/Dreamweaver100.
Access to the two level directory Dreamweaver100 of the remote virtual host through the above virtual address, the actual virtual address is http://www.4u2v.com/Dreamweaver100/dat because the database file is saved in the DAT folder.
Then, a asp.net vb dynamic page that includes only "" code, uploads the domain name address of the remote space as http://www.4u2v.com/Dreamweaver100, through the asp.net VB Dynamic page can obtain the physical path of the remote space To derive the physical address of the database file stored in the remote space.
(14) Here is an example:
Create a new blank asp.net VB dynamic page in Dreamweaver, switch to Code view, and enter the code .
Save it as dwurl.aspx and browse through IE, as shown in Figure 75-20.
In Figure 75-20, you can see that the physical path of dwurl.aspx in the server is C:inetpub wwwroot, and the physical path of the database is C:inetpubwwwrootdat dwdat. Mdb. After you get the physical path to the remote host, open the Web.config configuration file and fix it to the physical path in the server database.
The database link creation method described here is implemented through the UDL file creation. When developing ASP network applications in Dreamwaver MX, you can also create database links through the methods described in this example. The database "Dwdat.mdb" and the Database Connection "Dwconn" created by this instance will be applied to instances 76 through 90. At this point, the example operation is complete.
note : More wonderful tutorials Please pay attention to the triple Web design tutorial column,