ACC97: Using a File DSN or DSN-Less Connection with ASP files

This article has been archived. It is offered "as is" and will no longer be updated.
Advanced: Requires expert coding, interoperability, and multiuser skills.

When you export Microsoft Access 97 objects to ASP format, you provide thename of a System DSN on your Web server, which Microsoft Access uses in theConnectionString property of the ASP script that it generates.

You can modify the ASP script so that it uses either a File DSN or aDSN-less ConnectionString (by providing detailed connection information).This capability has the following advantages:
  • If you are not the administrator of the Web server, you do not have to ask the administrator to create a System DSN.
  • You can change the arguments in a File DSN or in the ASP ConnectionString without having to ask the Web server administrator to modify a System DSN.
  • If you are the administrator, you do not have to create multiple System DSNs for every person who wants to create Web pages that have database access.
  • File DSNs can be shared with other users.
NOTE: This article contains information about editing ASP files. Itassumes that you are familiar with Active Server, Visual Basic Scripting,and editing HTML files. Microsoft Access Product Support professionals do not support modification of any HTML, HTX, IDC, or ASP files.
More information
The following example shows you how to create an ASP file with MicrosoftAccess 97, and then modify it so that a System DSN is not required. Thissection is divided into these parts:
  • Important Notes
  • Copying Northwind and Your File DSN to the Web Server
  • Creating and Modifying the ASP File
  • Testing the ASP file

Important Notes

For the sake of simplicity, the example in this article instructs you tocopy all files to the same folder on your Web server. This is not arequirement, as long as the ConnectionString information in the ASP filecontains the correct path to the files. For example, the database and theFile DSN (if you use one) can be located on a network share, and you canuse universal naming convention (UNC) paths in your ConnectionString.

All files that you want to access require appropriate permissions on theWeb server computer. This includes IIS permissions, NTFS permissions, andnetwork share permissions. If IIS is configured to use Anonymous Accesswith an Internet Guest Account, then that account must have Read and Writeaccess to the folder in which the database resides. If you use a File DSN,then the Internet Guest Account must have Read access to the File DSN. Andif network shares and UNC paths are used in the File DSN or in theConnectionString, then the Internet Guest Account must have appropriatenetwork share permissions. For a detailed description of permissions issueswhen using ASP files, please see the following article in the MicrosoftKnowledge Base:
161333Check NT Permissions When Using IDC/ASP Files with Access

Copying Northwind and Your File DSN to the Web Server

You must have a folder on your Web server where you can copy files. Thefolder should be an IIS virtual directory with Execute permissions. Copythe Northwind sample database, Northwind.mdb, to this folder. Write downthe complete path to this file; you will need that information when youcreate the ConnectionString later. The path can use either a drive letteror a UNC name.

If you plan to use a File DSN in the ConnectionString instead of detailedconnection information, make sure the appropriate argument in your File DSNcontains the complete path to your database on the Web server (drive letteror UNC path). Copy your File DSN to the same folder on your Web serverwhere you place Northwind.mdb. Then, when you modify the ConnectionStringin the ASP file, you only need to provide a path to the File DSN.

For more information about creating File DSNs and DSN-less connections,please see the following article in the Microsoft Knowledge Base:
165866How to Use File DSNs and DSN-less Connections

Creating and Modifying the ASP File

If you are using a File DSN, please skip to the next section.
  1. Start Microsoft Access 97 and open the sample database Northwind.mdb.
  2. Export the Customers table to ASP format. When you are presented with the "Microsoft Active Server Pages Output Options" dialog box, leave the Data Source Name box blank.
  3. Use Notepad or another text editor to open the Customers.asp file. Look for the following line of code in the first If...End If block in the file: "","",""					
  4. Modify the ASP file to use either a DSN-less or File DSN connection.

    NOTE: In the following sample code, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this code.
    1. To use a DSN-less connection, modify the line in step 3 to provide the correct ConnectionString information. For example, if you copied Northwind.mdb to the C:\Inetpub\wwwroot\Test folder on your Web server, type the following as your ConnectionString: "driver={Microsoft Access Driver _(*.mdb)};dbq=c:\inetpub\wwwroot\test\northwind.mdb;uid=Admin"						
    2. To use a File DSN, modify the line in step 3 to provide the File DSN information. For example, if the File DSN is called Northwind.dsn and it resides in the C:\Inetpub\wwwroot\Test folder on your Web server, type the following as your ConnectionString: "FILEDSN=c:\inetpub\wwwroot\test\northwind.dsn", _"Admin", ""						
  5. Save and close the Customers.asp file. Copy the file to the same folder on your Web server where Northwind.mdb and your File DSN (if you areusing one) reside.

Testing the ASP File

  1. Start Microsoft Internet Explorer 3.0, or another Web browser program.
  2. Type the uniform resource locator (URL) in the address box of your Web browser to view Customers.asp. For example, if you copied your files toa folder called Test in the scripts folder of your Web server, type:
    Note that the URL depends on where your files are located on the WebServer.
  3. The Web browser returns the records from the Customers table inNorthwind.mdb.
For more information about exporting ASP files, search the Help Index for"ASP files," or ask the Microsoft Access 97 Office Assistant.

For more information on how to create and modify ASP files, please referto your Microsoft ASP online documentation.
data source name

Article ID: 167294 - Last Review: 01/11/2015 01:23:25 - Revision: 4.0

  • Microsoft Access 97 Standard Edition
  • kbnosurvey kbarchive kbhowto kbinterop kbprogramming KB167294