Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Web Page dsn less hook up to Access database

Status
Not open for further replies.

thunderain

Programmer
Jan 10, 2002
40
0
0
CA
Hi:

I am trying to put my asp program on a web server and trying to call up an access database. Should be simple. I have done several on my hard drive, works fine. I need to have it work on a web page. I called the server and they said i need a dsn less code hookup. Went on google found one but not working.

Here is the code I have:

set cnn = server.createobject("ADODB.Connection")
cnn.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=c:\test\testDB.mdb"

Here is the error I get:

Microsoft OLE DB Provider for ODBC Drivers error '80004005' [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides. /test/dsn.asp, line 6

line 6 is the second line above starting with cnn.open....


I'm not sure if its just a path problem. On the server, the database is on the same level as the asp program, in a file called test.

Any help would be apprecieted

Thanx
Thunderain
 
cnn.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=c:\test\testDB.mdb"

Its looking for this file on the machine the .asp page is located on, using the exact path you have specified. Instead of the path for your local machine (c:\test\) you either need to find out the exact one for your webserver or (better) change it to a relative path. Since the .mdb file is in the same directory as your .asp pages it should be as easy as:
Code:
cnn.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=testDB.mdb"

let us know if that works for you


Posting code? Wrap it with code tags: [ignore]
Code:
[/ignore][code]CodeHere
[ignore][/code][/ignore].
 
You should use SERVER.MAPPATH("Path to DataBaseName")... I saw It's very good for everything...
 
instead of:
Code:
set cnn = server.createobject("ADODB.Connection")
cnn.open "DRIVER={Microsoft Access Driver(*.mdb)};DBQ=c:\test\testDB.mdb"

Do this:
Code:
Set cnn = Server.CreateObject("ADODB.Connection")
sConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
              "Data Source=" & Server.MapPath("\ServerName\db\dbname.mdb") & ";" & _
              "Persist Security Info=False"
cnn.Open(sConnection)

If you are not using Server.MapPath, then you can change :
Code:
Data Source=" & Server.MapPath("\ServerName\db\dbname.mdb") & ";" & _
To the following:
Code:
"Data Source=\\ServerName\db\dbname.mdb" & ";" & _
So the modified script will be:
Code:
cnn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ 
        
           "Dbq=\\ServerName\db\users.mdb;"

HTH

-Tivoli0
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top