Link to home
Start Free TrialLog in
Avatar of lee88
lee88Flag for United States of America

asked on

ASP cannot open Access database

I just installed IIS on a Vista laptop and cannot open an Access database from ASP using LocalHost. Here’s the code:

dim cn, dbname
dbname = "C:\tempx\op.mdb"
set cn = server.createobject("ADODB.Connection")
cn.provider = "microsoft.jet.oledb.4.0"
cn.properties("data source") = dbname
Response.Write "Here 1 <BR>"
cn.open
Response.Write "Here 2 <BR>"

(I have unchecked “Friendly Error Messages”, but still cannot see the actual error message), but here is what I get when I run the code:

Here 1
An error occurred on the server when processing the URL. Please contact the system administrator

I am guessing that the error is generated when it tries to create the “LDB” file during the open operation, so I have temporarily opened up permissions as follows:
Regarding folder Permissions for C:\ tempx, I have given Full Control to Everyone as well as the Anonymous Login account.
Regarding file Permissions for C:\ tempx\op.mdb, I have given Full Control to Everyone as well as the Anonymous Login account.
I also gave Full Control to Everyone as well as the Anonymous Login account for the folder that the ASP program is in.

What else do I need to do to allow an ASP program to be able to open the Access database?
Avatar of lee88
lee88
Flag of United States of America image

ASKER

I figured out how to get the detailed error message. Here's what I get now:

Here 1
Microsoft JET Database Engine error '80004005'
Unspecified error
/kiosk/ASPtest.asp, line 9
Avatar of eivo
eivo

iis is a pain when you try and extract error messages out of it.

but it looks to me like you havent got a proper connection string

i.e.
cn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("C:\tempx\op.mdb")

simply create the object, then use that to open the connection

if you're having problems using that, you might want to define an infinately easier to manage DSN on your server and use the connection string:

adoCon.Open "DSN=whateverthedsnis"

to define a DSN you need to go to Control Panel -> Data Sources or Control Panel -> Administrative Tools -> Data Sources
Avatar of lee88

ASKER

eivo: Thanks for the suggestions. I tried your connection string and got the same error. Regarding setting up a DSN, when I get to the "ODBC Data Source Administrator" window, on the User tab, I selected "MS Access Database" and click "Add", then gave my new DSN a name (Test_mdb) and pointed it to the mdb file.

Here's the code:

dim cn, dbname
set cn = server.createobject("ADODB.Connection")
Response.Write "Here 1 <BR>"
cn.open "DSN=Test_mdb"
Response.Write "Here 2 <BR>"
Response.End

 Here's the result:

Before fso.CopyFile
After fso.CopyFile
Here 1
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
/kiosk/ASPtest.asp, line 12

Did I leave something out?
Also, do I do this under the "User DSN" tab as opposed to the "System DSN" or "Fiile DSN" tabs?
ASKER CERTIFIED SOLUTION
Avatar of eivo
eivo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial