Solved

ASP cannot open Access database

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Familiarize people with the process of utilizing SQL Server views 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 Access…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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