In the instance of the "Building a development environment" in the development of web applications have been built for the good of the development environment, but to develop web-based database, the database connection must do the work. Will start from the example of a toy company e-commerce platform development, for example, explain in detail Dreamweaver + ASP.NET + Access network database development process. The main examples to explain the database connection technology.
Results shows
】 【Database by clicking the panel】 【OLE DB connections, create and Access database connection "dwconn", the results shown in Figure 75-1.
Creative thinking
E-commerce platform of a toy company's database from the DreamweaverCP table, DreamweaverGL composition tables and DreamweaverKH table. DreamweaverCP table used to store information on the company's products; DreamweaverGL table used to store information of the company administrator; DreamweaverKH table used to store information on the company's customers. First, create a database in Access "dwdat.mdb", and create three data tables, and then in the Dreamweaver site "Dreamweaver100" (in the instance of the "Building the development environment" in already created the site) to create the database connection for e-commerce platform.
Steps
(1) copy the good "dwdat.mdb" file and use Access to open. The "75 instances of the source file CD-ROM" directory of the database file "dwdat.mdb" Copy to "C: Inetpubwwwrootdat" directory (the directory as an example a construction site in the "Dreamweaver100" under the directory), the Open in Access "C: Inetpubwwwrootdatdwdat.mdb" file, the database "dwdat.mdb" includes "DreamweaverCP", "DreamweaverGL", "DreamweaverKH", "CPDD" and the "POLL" 5 tables of data, including "DreamweaverCP" table used to store the information on the company's products, the data structure shown in Figure 75-2; "DreamweaverGL" form is used to manage the company's personnel information, the data structure shown in Figure 75-3; "DreamweaverKH" table used to store the the company's user registration information, the data structure shown in Figure 75-4; "CPDD" table used to store the company's product order information, the data structure shown in Figure 75-5; "POLL" table is used to store The company's online survey, the data structure shown in Figure 75-6.
(2) New dynamic pages. Run Dreamweaver MX 2004, select 【File】 | 【New】 menu command, in the pop-up】 【New Document dialog box, create a file named "ASP.NET VB" dynamic page, as shown in Figure 75-7.
Tip: Here are two examples of sites created to develop the toy company's network applications, the establishment of the site, please refer to Example 2.
(3) create a database connection "dwconn". Switch to the Database panel, click 【+】 button, the pop-up menu, select OLE DB connection】 【create a database connection "dwconn", as shown in Figure 75-8.
Tip: In step 2 shown in Figure 75-7, because the database connection here is the Access database, it should be chosen】 【OLE DB connection, and when you want to connect when the database is SQL SERVER, SQL server connection should be chosen 【 】.
Shown in Figure 75-7 in step 4, if you click 【】 button to establish nothing happens, it will not open】 【Data Link Properties dialog box. This problem occurs as a result may be due to MDAC 2.8, XP SP2 and Windows2003 by default contains MDAC 2.8. XP SP1 users If you install MDAC 2.8, will also be affected by this problem, details please refer to http://www.macromedia.com/cn/support/dreamweaver/ts/documents/dw_xp_sp2.htm # build.
(4) create a "database connection. Udl". Click 【Start】 | 【All Programs】 | 【accessories】 | 【】 menu command in Notepad, create a blank notebook, and named it as "the database connection. Udl" (file name can be readily obtained, but the file name suffix must be ". udl", not ". txt", storage location can be easily set up), as shown in Figure 75-9. This example is the "database connection. Udl" saved on the desktop.
Tip: What is UDL documents? UDL is a universal data connection file, the file can be saved through the connection string. Database connection using UDL file storage methods and use "ODBC Data Source Name (DSN)" are very similar. OLE DB UDL files to store connection information, such as provider, user name, password and other options.
[Next]
(5) Select the OLE DB provider. Close the notebook, with the left mouse button double-click the "database connection. Udl", Open】 【Data Link Properties dialog box, switch to the provider】 【window, select the OLE DB provider 【】 list "Microsoft.Jet OLE DB 4.0 Provider ", click the Next Steps button, as shown in Figure 75-10.
(6) Select and test the connection database. In the 【】 tab, select Connect to connect the database and test the connection, as shown in Figure 75-11.
(7) copy the database connection command. Click the right mouse button, the pop-up shortcut menu, select 【Open】 | 【NOTEPAD】 menu command to open the notebook, "the database connection. Udl", copy the database connection command, as shown in Figure 75-12.
(8) test the database connection. Switch to Dreamweaver, paste the database connection command, and to test the database connection, as shown in Figure 75-13.
(9) in the test database connections, if the dialog box shown in Figure 75-14, or the dialog box shown in Figure 75-15, shows the current system is not the proper allocation of user rights to modify the database, etc. operation.
The solution is as follows:
① Open the "c: Intepudwwwroot" folder, do 【Open】 | 【】 Folder Options menu command, the pop-up】 【Folder Options dialog box, remove the Use simple file sharing】 【the check, as shown 75-16 below.
② Click the right mouse button, the pop-up shortcut menu, select 【Properties】 menu item, then the pop-up】 【dat Properties dialog box set the "ASP.NET Web Admin" user permissions, as shown in Figure 75-17.
③】 in 【dat Properties dialog box, set the "Internet Guest Account", "start the IIS process account" permissions to allow modification.
(10) If the test is successful, but the database】 【Form】 【start panel entries, only a "no" character, not show data table, as shown in Figure 75-18, then use the following solutions.
① exit Dreamweaver, double-click "CD-ROM source file examples 75 SP2DBFix 1.0.2. Mxp" to install the extension file.
② Run Dreamweaver, site implementation 【】 | 【High】 | 【】 menu command to remove the connection script.
③ once again test the database connection, database】 in 【Form】 【start panel entries, you can expand the data table.
(11) then the root of the site will add a new file "web.config", explain it to complete the database connection is working, the results shown in Figure 75-1.
Note: In Step 4 shown in Figure 75-8, click the 【】 button to establish, will be able to directly open】 【Data Link Properties dialog box, without having to create a "database connection. Udl" and copy its data link command, 】 【Data Link Properties dialog box, set the database can be directly related to connection, shown in Figure 75-10 and Figure 75-11.
(12) Check the physical path. Since Dreamweaver MX is to connect to the database commands stored in the web.config configuration file, so just open the web.config configuration file, and switch to code view, we can see the frame as shown in Figure 75-19 in the physical path .
(13) Get the database path to the remote host. As the site will eventually be uploaded to a remote server, so the physical paths are generally not the same as the local physical path, and also in the web.config configuration file can not be used, such as server variables like Server.MapPath to obtain long-range space the physical path of the database. But may be other ways to get the database on the remote host directory physical path of the real. From the first assumption that the domain address of the remote space http://www.4u2v.com/Dreamweaver100.
Through the above virtual address to access the remote host two virtual directories Dreamweaver100, because the database file in dat folder, so the actual virtual address http://www.4u2v.com/Dreamweaver100/dat.
Then, a only "<% = server.MapPath (" ")%>" code of ASP.NET VB dynamic pages, upload the domain address of the remote space http://www.4u2v.com / Dreamweaver100, dynamic pages through the ASP.NET VB can get the physical path to the remote space out to arrive at the database file stored in the physical address of the remote space.
[Next]
(14) Here an example:
In Dreamweaver, create a blank ASP.NET VB dynamic page, switch to code view, enter the code <% = server.MapPath ("")%>.
Save as dwurl.aspx, browse in IE, the results shown in Figure 75-20.
As can be seen in Figure 75-20 dwurl.aspx in the server's physical path is C: Inetpub wwwroot, while the database of the physical path C: Inetpubwwwrootdat dwdat. Mdb. Get the physical path to the remote host, open the web.config configuration file, upload to a server database to amend the physical path.
Described here is to create the database link created through the UDL file to achieve. Dreamwaver MX to develop in ASP Web applications, they can be described by the example of the method to create the database link. This instance of the Create Database "dwdat.mdb" and the database connection "dwconn" will be applied to instances of 76 to 90 in the instance. Thus, this instance of the operation is completed.
For more examples, please read "Dreamweaver web design and production of selected examples."