PRB: "Couldn't find file 'Unknown'" Error when Language=JScriptID: Q189206
|
When the default language is set to JScript for Active Server Pages (ASP) pages 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:Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access 97 Driver] Couldn't find file '(unknown)'.
"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:Server object error 'ASP 0177 : 800a0034'
Server.CreateObject Failed
fl = fs.OpenTextFile("c:\\myfile.txt", 1, 0,0);
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.
There are several possible workarounds:
This behavior is by design.
Additional query words: kbADO kbASP kbVisID
Keywords : kbASPObj kbODBC kbVisID100 kbVisID600 kbGrpASP
Version : WINDOWS:1.0,1.5,6.0
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: May 13, 1999