Article ID: 189206
Article Last Modified on 7/20/2004
APPLIES TO
- Microsoft Visual InterDev 1.0 Standard Edition
- Microsoft Visual InterDev 6.0 Standard Edition
- Microsoft Data Access Components 1.5
- Microsoft Data Access Components 2.1
- Microsoft Data Access Components 2.5
- Microsoft Data Access Components 2.6
- Microsoft Active Server Pages 1.0
This article was previously published under Q189206
SYMPTOMS
When the default language is set to JScript for Active Server Pages (ASP) connecting to a file-based database (for example, Access, Visual FoxPro) returns an error such as the following:
This error occurs only with connect strings that contain discrete or UNC paths such as "c:\newdata\backup.mdb" or \\servername\sharename\backup.mdb, respectively. For example, adding a data connection to a Visual InterDev 1.0 Web Project for the adventure works database from within Visual InterDev 1.0 would create the following connection string in your Global.asa:
"DSN=AdvWorks;DBQ=C:\InetPub\ASPSAMP\AdvWorks\AdvWorks.mdb; DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5;");
When trying to open a text file, an error occurs such as the following:
This error occurs when calling GetFile or OpenTextFile as in the following:
fl = fs.OpenTextFile("c:\\myfile.txt", 1, 0,0);
CAUSE
The error is due to the backslash character (\) being used as a delimiter both in file paths and as the identifier for "escape sequences" in JScript.
Examples of escape sequences are "\n" for a new line or "\b" for a backspace. Two backslashes (\\) resolve to a single backslash. If the character following the backslash is not a known escape sequence identifier, the backslash is ignored.
As a result, JScript resolves the string "c:\newdata\backup.mdb" to "c: ewdataackup.mdb" where the "\n" is replaced with a carriage return and the "\b" is replaced with a backspace. JScript would resolve "\\servername\sharename\backup.mdb" to "\servernamesharenameackup.mdb" where the "\\" is replaced with a single backslash and "\b" is replaced with a backspace.
In cases such as these, the resulting string passed to the Connection.Open method is an invalid file location, resulting in an error.
RESOLUTION
There are several possible workarounds:
- Replace all backslashes (\) in your connect strings with two backslashes (\\). For example: "\\\\servername\\sharename\\backup.mdb" would resolve to "\\servername\sharename\backup.mdb."
- Use VBScript instead of JScript.
- Store all path information in an ODBC DSN and only pass the DSN name to the Connection.Open method as in: Connection.Open "MyDSN."
STATUS
This behavior is by design.
REFERENCES
For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
253604 Microsoft Access 97 database connectivity fails in Active Server Pages
253580 How to connect to a remote Access database from Active Server Pages
Additional query words: error 80004005 800a0034
Keywords: kberrmsg kbscript kbaspobj kbprb kbmdacnosweep KB189206