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
'rs.Close
'cn.Close
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?
Jay
|