Solved

ASP cannot open Access database

Posted on 2007-04-03
4
342 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

758 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

19 Experts available now in Live!

Get 1:1 Help Now