Working with Databases with Dreamweaver MX in a Lab Setting

In the GMU Robinson 3rd floor classroom, there are two problems working with dynamic sites with Dreamweaver MX:

  1. Internet Information Services (IIS) is either not installed or not working.  IIS is not installed in a default Windows XP Professional installation but can be added by selecting Control Panel>Add or Remove Programs and then clicking Add/Remove Windows components in the left navigational bar and then selecting Internet Information Services.  Active Server Pages (ASP) can be tested using IIS, thus eliminating the need to transfer the program to a remove server to test the file.
  2. One way of linking to a database is through the use of a DSN (data source name).  The procedure in Windows XP is Control Panel>Administrative Tools>ODBC Data Sources>System tab>Add>select the driver from the list and click Finish, and then enter a name for the data source (a DSN) and then click Select to browse for the database.  In Dreamweaver, one then uses this DSN to get access to the database.  In the Robinson classroom, one can't create a new system DSN, probably because these are written to the Registry.  Although the DSN method of connecting to a database is often the method taught in texts (e.g. Dreamweaver MX The Missing Manual by McFarland (p. 629-630), Internet & World Wide Web How to Program, Second Edition, p. 833 by Deitel, Deito, and Nieto), even if this procedure works on the computer on which the site is being created, for it to work once the files are transferred up to the server requires that the web developer be able to create a DSN on the server.  In many environments, this is either impossible to do or requires the assistance of whoever is administering the server.

With regard to the first issue, in the absence of IIS, one must rely on the use of a remote server.  www.brinkster.com provides web space where one can host ASP applications; this hosting is free for educational users.  However, one cannot FTP to the free site but must use Brinkster's web-based file manager and thus one cannot use brinkster.com as a testing server in Dreamweaver MX because the connection is established via FTP.  The Mason server (mason.gmu.edu) and the NVCC student server also do not support ASP pages, but the NVCC Faculty server does.

With regard to the DSN issue, using the MapPath method of the Server object is my recommended alternative.  This is discussed in the Third Edition of Internet & World Wide Web How to Program by Deitel, Deitel, and Goldberg (p. 828-829) and the Dreamweaver MX help under "Virtual Path" and the "related topics" referenced therein, especially "Using a virtual path to connect to a database."  Understanding the use of this method requires understanding the difference between a virtual path and a physical path.  For example, in the URL www.deitel.com/books/index.html, books/index.html is the virtual path to the file located on the web server hosting www.deitel.com.  The physical path refers to the actual location of the file on the machine running the server and will reference the drive letter.  When one connects to a database through the use of a connection string rather than the use of a DSN, the physical path to the database is required.  This presents two problems.  First, in many hosting situations, the web developer has no idea of the physical location of the database.  Second, even if this location is known, the location will change when the file is transferred from the local site to the remote site and thus the connection string must be changed as well for the remote site which is contrary to the usual web development principle whereby files can be transferred from the local site to the remote site unchanged and they will work in both locations.

The MapPath method of the Server object takes as an argument the virtual path and returns the corresponding physical path as a string, and thus the MapPath method can be used in the connection string to provide the needed physical path to the database which solves both of the problems above - knowing the physical path and having different code in the local and remote site due to the difference in the physical path to the database.

It is unclear in my view whether the Dreamweaver help screens suggest using the MapPath method directly when asked to enter a connection string in the following dialog box that one gets by clicking the + sign on the Databases Panel>Custom Connection String, selecting either the Using Driver on Testing Server or Using Driver on This Machine option.


My attempts to do so did not work.  The VB Script version of the connection string used was

"Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/db/login.mdb")

A better approach would be to replace the Server.MapPath expression in this dialog box with the physical path on the local machine.  In my tests, one could enter a relative path to the file rather than an expression beginning with a drive letter.  In any event, using such a local connection will enable the connection to be made, and then the connection string can be replaced with a MapPath expression before uploading to the server.  Alternatively, one can upload an ASP file to the testing server with the following expression:<% Response.Write(Server.MapPath("/db/login.mdb")) %> where one replaces "/db/login.mdb" with the logical path to your database.  This will display on the screen the physical path on the testing server and then one can use this in the connection string expression above, i.e. DBQ=physical path but this will mean that one has to again change the connection string when the file is moved to the production server, whereas using the MapPath method avoids that.

Revised: December 14, 2004.  Comments to William Pegram, wpegram@nvcc.edu