Solved

ASP cannot open Access database

Posted on 2007-04-03
4
343 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:lee88
  • 2
  • 2
4 Comments
 

Author Comment

by:lee88
ID: 18842373
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
0
 
LVL 4

Expert Comment

by:eivo
ID: 18843072
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
0
 

Author Comment

by:lee88
ID: 18844193
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?
0
 
LVL 4

Accepted Solution

by:
eivo earned 500 total points
ID: 18844517
it needs to be done under systemDSN in order for you to be able to connect from iis
you also should make sure that you use the correct driver for access,

also make sure that you have not set a username and password on your access database (it's not usual)

connectionstring in this event would be
"DSN=test_mdb;UID=username;PWD-password"

you will then need to create a recordset to output your data,
i.e.

dim recordset
dim query
set recordset = server.createobject("ADODB.Recordset")
query = "SQL QUERY HERE"
recordset.open query, cn  'then add whatever cursors or pointers you fancy, e.g. 3,3

and you're ready to roll

hope this is useful to you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now