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!

Connecting To MS Access Database Question

Status
Not open for further replies.

JR4VB

Technical User
Jan 13, 2003
36
0
0
US
I am using an asp to query against an Access Database file located in c:\ I created a System DSN to point to this Database file, which doesn't use security. I use the following lines in the asp..
Set RS = CreateObject("ADODB.Recordset")
Set Conn = CreateObject("ADODB.Connection")
Conn.ConnectionString ="DSN=MyDatabase;"

When I execute the ASP I get an error..
"Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Could not find file 'C:\WINNT\system32\database.mdb'"

It always wants to look in System32 for the database even though the DSN points to c:\database.MDB

I have also tried..... Conn.open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath(/../../"database.mdb") With no Luck.

Though if I copy the database from c:\ to c:\winnt\system32 everything works just fine. The problem is in the future this database will be located on a network share drive.
If you know whats causing it to look in the system32 directory and nowhere else please let me know.
Thanks,

JR
 
I take it that the database is stored on your server.

Try linking via DSN-less connection, as info would go it is supposed to be a faster connection and your define where the database is within your page.

dbPath = "c:\database.mdb"
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & dbPath & ";"

This defines the exact path without having to back pedal from your web folder

Hope this works





daveJam

*Is this where we put the lonely hearts bit*
 
This is the way I'm trying to do it now not using a DSN

Set RS = CreateObject("ADODB.Recordset")
Set Conn = CreateObject("ADODB.Connection")
Conn.Provider = "Microsoft.Jet.OLEDB.4.0"
Conn.ConnectionString ="C:\DataBase.mdb"

Conn.open
Rs.Open SQL, Conn

It still looks in C:\winnt\system32. On accident the first time I spelled the database name wrong and it had an error could find file "c:\daatbase.mdb" So I thought good I'll just fix the spelling error and everything will work. So I changed it to "c:\database.mdb" Then I got the error could not find file "c:\winnt\system32\database.mdb"

So basically If I miss Spell the database name wrong in the "Conn.Connectionstring" property it looks in the correct directory and if I spell the database name right it always looks in "c:\winnt\system32".....
So far I have tried 4 different methods of getting to this database...... It's driving me crazy

JR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top