Accessibility
 
Home > Products > UltraDev > Support > Connecting to a Database
Dreamweaver UltraDev Icon Macromedia Dreamweaver UltraDev Support Center - Connecting to a Database
Using a virtual path to connect to a database

To write a DSN-less connection string to a database file on a remote server, you must know the physical path to the file. For example, here is a typical DSN-less connection string for a Microsoft Access database:

Driver={Microsoft Access Driver (*.mdb)};
DBQ=c:\Inetpub\wwwroot\accounts\users\jsmith\data\statistics.mdb

If you don't know the physical path of your files on the remote server, you can get the path by plugging a Server.MapPath expression into your connection string.

To create a DSN-less connection with a Server.MapPath expression:

1 Upload the database file to the remote server.
Make a note of its virtual path—for example, /jsmith/data/statistics.mdb.
2 Open one of your site's pages in UltraDev and choose Modify > Connections.
The Connections dialog box appears.
3 Click New and select Custom Connection String from the pop-up menu.
The Custom Connection String dialog box appears.
4 Enter a name for the new connection.
5 Enter the connection string and use the Server.MapPath method to supply the DBQ parameter.
For example, suppose the virtual path to your Microsoft Access database is /jsmith/data/statistics.mdb. The connection string can be expressed as follows if you're using VBScript as your scripting language:
"Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/jsmith/data/statistics.mdb")
The ampersand (&) is used to concatenate (combine) two strings. The first string is enclosed in quotation marks and the second is returned by the Server.MapPath expression. When the two strings are combined, the following string is created:
Driver={Microsoft Access Driver (*.mdb)};¬
DBQ=C:\Inetpub\wwwroot\accounts\users\jsmith\data\statistics.mdb
If you're using JavaScript, the expression is identical except that you use a plus (+) sign instead of an ampersand (&) to concatenate the two strings:
"Driver={Microsoft Access Driver (*.mdb)};DBQ=" + Server.MapPath("/jsmith/data/
statistics.mdb")
6 Select the Using Driver On Application Server option.
Macintosh users can ignore this step because all database connections use the application server.
7 Click Test.
UltraDev attempts to connect to the database. If the connection fails, double-check the connection string.
If the connection still fails, contact your ISP to make sure the database driver you specified in the connection string is installed on the remote server. Also check that the ISP has the most recent version of the driver. For example, a database created in Microsoft Access 2000 will not work with Microsoft Access Driver 3.5. You need Microsoft Access Driver 4.0 or later.
8 Click OK.
Your new connection should now appear in the Connections dialog box.
9 Click Done to close the Connections dialog box.
10 Update the database connection of existing dynamic pages, and use the new connection with any new page you build.
To change the connection of a dynamic page, open the page in UltraDev, double-click the recordset name in the Data Bindings or Server Behaviors panels, and select the connection you just created from the Connection pop-up menu.
To Table of Contents Back to Previous document