Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 5th, 2006, 01:52 PM
Registered User
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems opening MS Access database

I'm using the following code in an ASP page (obviously there's more but this is the minimal testing code):

'create ADO objects
Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")

'Open connection.
strDBlocation = Request.ServerVariables("APPL_PHYSICAL_PATH") & "database\NDTdatabase.mdb"
strConn = "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & strDBlocation & ";"
Response.write strConn
cn.Open strConn


The web server is on the same computer (Windows XP with IIS 5.0) that I'm using for development. Originally, I had the web application and database in an IIS virtual directory.

The error message I get from the cn.open strConn statement is:

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.

Commenting out the cn.Open statement, the Response.write displays:

Driver={Microsoft Access Driver (*.mdb)}; DBQ=c:\inetpub\wwwroot\database\NDTdatabase.mdb;

I moved the application directly under wwwroot and moved the database to the same directory as the asp file to see if that would solve the problem. I commented out the strDBlocation, strConn, and previous cn.open statements and added the following:

cn.Open Driver={Microsoft Access Driver (*.mdb)}; DBQ=NDTdatabase.mdb;

I got the following error message:
Microsoft VBScript compilation (0x800A0408)
Invalid character
/Classes/test.asp, line 109, column 15
cn.Open Driver={Microsoft Access Driver (*.mdb)}; DBQ=NDTdatabase.mdb;

I finally realized that the complaint was for the character after the =, so I put the Driver argument in quotes:

cn.Open Driver="{Microsoft Access Driver (*.mdb)}; DBQ=NDTdatabase.mdb;"

Now, I've got the error message:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/ndt/classes/test.asp, line 109

Eventually, I would like to have the database in a separate directory because it is accessed by several asp programs in several different directories.

I'm going nuts. Does anyone have any ideas?

Old June 5th, 2006, 01:59 PM
Friend of Wrox
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi

hi there.. try this..

build an udl file and construct the connection string in there... to connect to an access database use jet oledb 4.0 (it will connect to any version of an access database)...

then copy the connection string to your app. that will sure solve your problem with the connection...



Similar Threads
Thread Thread Starter Forum Replies Last Post
Database migration MS Access 2003 to MS SQL 2000 ayazhoda SQL Server 2000 3 April 23rd, 2007 11:38 AM
Backing up an MS Access Database donrafeal7 Access VBA 2 October 11th, 2006 11:33 AM
writing to a ms access database angel79 Classic ASP Databases 2 May 25th, 2005 11:03 AM
Access issues with ASP and a MS Access Database rj_conceptsnrec.com Classic ASP Databases 2 May 19th, 2005 12:44 PM
Problems with Export to MS Access sammiebarnes SQL Server DTS 3 August 15th, 2003 08:54 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.