Link to home
Start Free TrialLog in
Avatar of KenAdney
KenAdney

asked on

problems connecting to db

Built some ASP pages (the last 2 links at http://olympiapbia.org) that connect to an Access db.  They work fine on a previous server but have moved them to their present location and am having problems with the db connectivity.  Hosting company isn't much help.  Here's the code (and error msgs):

DataConn.Open "DBQ=" & Server.Mappath("xxxxx.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};" gives the error msg
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver]General error Unable to open registry key 'Temporary (volatile) Jet DSN for process 0x6f4 Thread 0x918 DBC 0x22a3ffc Jet'.

so I tried

DataConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("../xxxxxx.mdb") whcih gives
Server.MapPath() error 'ASP 0172 : 80004005'
Invalid Path
The Path parameter for the MapPath method must be a virtual path. A physical path was used.

I know the server is running MDAC v2.7 SP1 and IUSR is supposed to have read/write capabilities to this directory.

Any suggestions?
Avatar of jmundsack
jmundsack
Flag of United States of America image

Could it be that .MapPath wants just the path, not the .mdb file?
Avatar of rockymagee
rockymagee

Give this a shot:

Set MyConn = Server.CreateObject("ADODB.Connection")
MdbFilePath = Server.MapPath("XXXXX.mdb")
MyConn.Mode = 3
MyConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & MdbFilePath & ";"

' SQL QUERY
SQL_query = "SELECT * FROM yourTable"
Set RS = MyConn.Execute(SQL_query)
WHILE NOT RS.EOF
' *******************************
' *******************************
RS.MoveNext
MyConn.close
Avatar of Carl Tawn
If your host is using IIS6 then parent paths (i.e. using .. in the path) is disabled by default. Your best bet, if you can't get your host to enable parent paths, is to provide the virtual path to the DB.
Do a Response.Write(Server.Mappath("xxxxx.mdb")) to make sure it is the correct path.

It can also be permission problem on the TEMP folder, so make sure your IUSR account has read/write permissions on the temp folder.  Make sure they also have permissions to the actual mdb file and not just the directory.
Here are some instructions to set the permissions for your TEMP folder:

   1. Open the Windows (file) Explorer.
   2. Find the \WINNT\Temp directory.
   3. Right click and select "Temp Properties".
   4. In the resulting panel click on the "Security" tab.
   5. Now click the "Add" button.
   6. In the new "Select Users ..." panel (the top list box) select the user entity whose first 5 characters are "IUSR_", which is the Internet Guest User.
   7. (After adding the IUSR you will be back in the "Security" tab in "Temp Properties" panel.)
   8. In the "Permissions" box allow only List Folder Contents, Read, and Write permissions.
   9. It also very important to click the checkbox saying "Allow inheritable from parent to propagate this object".
Don't know if it will help, but try this:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../xxxxxx.mdb"

Preece
try this

DataConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("xxxxxx.mdb")
Avatar of KenAdney

ASKER

Thanks one & all...I've upped the points a bit.

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../xxxxxx.mdb" and the more complete DataConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("xxxxxx.mdb") gives
Microsoft JET Database Engine error '80004005'
Unspecified error

Response.Write(Server.Mappath("xxxxx.mdb")) reports e:\www\olympiapbia\xxxxx.mdb but I don't know what to do that.  If I change Server.Mappath("xxxx.mdb") to Server.Mappath("e:\www etc.") I get the same "Path parameter for the MapPath method must be a virtual path" error.

rockymagee's coding gives me the "Unable to open registry key"  error.

I'll contact the hosting company about write permissions for the file and the temp folder.
Give this a try:

DataConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=../xxxxxx.mdb"

Preece
Oh, didn't see that you had tried that before my last post...

Preece
If there's no refund of the points, just split 'em up between those who offered solutions...even though none were truly effective.  I appreciate everyone's help.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

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