beautypg.com

Edit or delete a database connection – Adobe Dreamweaver CC 2014 v.13 User Manual

Page 605

background image

To the top

Use a virtual path to connect to a database

To write a DSN-less connection string to a database file located on a remote server, you must know the physical path to the file. The following
example 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 using the MapPath method in your connection
string.

1. Upload the database file to the remote server and make a note of its virtual path—for example, /jsmith/data/statistics.mdb.

2. Open an ASP page in Dreamweaver, then open the Databases panel (Window > Databases).

3. Click the Plus (+) button on the panel and select Custom Connection String from the menu.

4. Enter a name for the new connection, without spaces or special characters.

5. Enter the connection string and use the MapPath method to supply the DBQ parameter.

Suppose that the virtual path to your Microsoft Access database is /jsmith/data/statistics.mdb; the connection string can be expressed as
follows if you use 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 use 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 Using Driver On Testing Server, click Test, and then click OK.

Note: Macintosh users can ignore this step because all database connections use the application server.
Note: If the connection fails, double-check the connection string or contact your ISP to make sure that 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.

7. Update the database connection of existing dynamic pages (open the page in Dreamweaver, double-click the recordset name in the

Bindings panel or Server Behaviors panel, and select the connection you just created from the Connection menu) and use the new
connection with any new page you build.

Edit or delete a database connection

When you create a database connection, Dreamweaver stores the connection information in an include file in the Connections subfolder in the
site’s local root folder. You can edit or delete the connection information in the file manually or as follows.

Edit a connection

1. Open an ASP page in Dreamweaver and then open the Databases panel (Window > Databases).

2. Right-click (Windows) or Control-click (Macintosh) the connection and select Edit Connection from the menu.

3. Edit the connection information and click OK.

Dreamweaver updates the include file, which updates all the pages in the site that use the connection.

Delete a connection

1. Open an ASP page in Dreamweaver and then open the Databases panel (Window > Databases).

2. Right-click (Windows) or Control-click (Macintosh) the connection and select Delete Connection from the menu.

3. In the dialog box that appears, confirm that you want to delete the connection.

Note: To avoid receiving errors after deleting a connection, update every recordset that uses the old connection by double-clicking the
name of the recordset in the Bindings panel and choosing a new connection.

More Help topics

598

This manual is related to the following products: