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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A Most Unusual Path Problem

Status
Not open for further replies.

prgmrgirl

Programmer
Feb 12, 2004
119
US
Hey guys,

Well, I'm stumped. I wrote a simple html file and .js file that connects to an access database.

It seems, from the error I'm getting, that somehow, my connection string is being changed when I try to open my page. Something is adding "C:\Documents and Settings\Owner\Desktop" to whatever path I have written in my connection string.

Anyone know what's doing this or how I can change it?

Thanks!
prgmrgirl
 
Please post the code for

1) Setting the connection string plus all the bits that make up the string
2) Opening the connection

 
sure thing:

Code:
var cnn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\myDatabase.mdb;"
var strSQL = "SELECT custName FROM Customers WHERE custID='123'"

var dbCnn= new ActiveXObject("ADODB.Connection")
dbCnn.Open(strCnn)

var rst = new ActiveXObject("ADODB.Recordset")
rst.Open(strSQL,dbCnn)

The error I am getting is:

"Cannot find file C:\Documents and Settings\Owner\Desktop\myDatabase.mdb"

That's because the database is not there, its in C:\myDatabase.mdb just like I put in the connection string.

Please note: the code WORKS if I actually put it in the desktop folder. Somehow, the prefix "C:\Documents and Settings\Owner\Desktop\" is being added to whatever string I use as the path in the connection string. For example, if the connection string has the path

"C:\My Documents\myDatabase.mdb"

it becomes

"C:\Documents and Settings\Owner\Desktop\My Documents\myDatabase.mdb"

Thanks for your help!
 
Ok I figured it out. It has to do with how \ is handled.

When I changed the connection string from:

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\myDatabase.mdb;"

to

"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\myDatabase.mdb;"

the actual path that I specified was picked up.

Thanks!
prgmrgirl
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top