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

ISAM

Status
Not open for further replies.

sohjai

Programmer
Nov 23, 2001
8
HK
I have a connection string

strconn="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
Server.MapPath("test.mdb") & ";PWD=1234"

and when I tried to connect to the database then I got a error message : Cannot Find Installable ISAM

so may I ask what is going wrong and how to fix it?
 
An ADO data source string can contain modifiers. This means that there are two sets of semicolons within a connection string. One set delimits property settings (Provider, Data Source, UID, PWD, Extended Properties, Initial Catalog, etc.). The other set delimits "modifiers" within the value string for each property.

Ok, that's clear as mud.

It doesn't help that ADO will try hard to help you out, parsing the connection string and taking guesses at which are "major" semicolons and which just set off modifiers. This means one string works fine, another string looks like it ought to work too but it doesn't.

You can be more explicit by using quotes within your connection strings. This might work just fine.

Fig 1.
Code:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=test.mdb;PWD=1234
This may not:

Fig 2.
Code:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=my test.mdb;PWD=1234
And if your Data Source string is complex, like a full path and file name, you can really start having troubles. Instead try:

Fig 3.
Code:
Provider="Microsoft.Jet.OLEDB.4.0";Data Source="my test.mdb";PWD="1234";
I quoted the property value strings, and I added that redundant-seeming semicolon at the end too. It doesn't hurt, I feel it shouldn't be needed, but MS uses a lot of C developers who haven't a clue that semicolons are separators rather than terminators in programming languages here on Planet Earth.

You might even find that your code would work fine if you had a UID value assignment in there. Sometimes things like that help "clue in" ADO about what it is playing with when it does its double-scan of connection strings trying to assign semicolon levels.

Ok, that "semicolon level" bit. I need to explain that more.

Fig 4.
Code:
Provider="Microsoft.Jet.OLEDB.4.0";Data Source="my test.xls";
Extended Properties="Excel 8.0;HDR=No";PWD="1234";
See how this example has a property setting for Extended Properties, and how there are two semicolon-delimited substrings in the value string? The semicolon before the "HDR=No" part is one of these second level semicolons. Just a note here: if you put a semicolon after the "No" and before the quote it will die on an ADO error. Weird and inconsistent I know.

The point of all of this is... I think that ADO and/or the Jet OLEDB Provider are getting confused and are passing something strange to that part of Jet that handles opening the data source. It doesn't look like you want an MDB, so the software scans for an installable ISAM module for an external data source type and fails to find a match.

I suggest you try:

Fig 5.a.
Code:
strconn="Provider=""Microsoft.Jet.OLEDB.4.0"";Data Source=""" & _
         Server.MapPath("test.mdb") & """;PWD=""1234"";"
Or:

Fig 5.b.
Code:
strconn="Provider='Microsoft.Jet.OLEDB.4.0';Data Source='" & _
         Server.MapPath("test.mdb") & "';PWD='1234';"
Please note that (5.a.) is preferable because the apostrophe (') is a valid file name character, and one more likely to be used than a quote ("). In theory the odds that Server.MapPath( ) will return a string with an apostrophe in it (and break your connection string) are higher than that a quote will be in the returned value.

To be really safe, you ought to use
Code:
Replace(Server.MapPath("test.mdb"), """", """""")
to double-up the quotes in (5.a.). You could also use
Code:
Replace(Server.MapPath("test.mdb"), "'", "''")
with (5.b.) instead.

In your particular case you probably got burned by a blank space before the phrase Data Source. That means you might get away with:

Fig 6.
Code:
strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
         Server.MapPath("test.mdb") & ";PWD=1234"
In other words just deleting the blank space.

The moral of the story is that you must be explicit about what you want, or the string will be parsed twice and rules that aren't clear will be applied to figure out what fits where in the property hierarchy.

The specific error you got almost always means you have messed up your connection string in some subtle way.
 
Dear dilettante and others;
(thread329-524716)

Thanks for the tip on the thread above,
was up to now the one that made the most
sense but it does not work either, neither
of your options...

It seems that the only way to access the DB
using PWD is throught the string:

dsn = "Driver={Microsoft Access Driver (*.mdb)};" & "DBQ=d:\inetpub\database\empresas\barrasol\AES.mdb;" & "PWD=456456"

and the other one only works if the db is not pwd protected:

dsn = "Driver={Microsoft Access Driver (*.mdb)};" & "DBQ=" & Server.Mappath("AES.mdb") & ";"

THERE IS NOTHING TO DO WITH PATH, but it sure have
some to do with syntax, but what is it remains unknown!

Thanks
Alex.




Alexandre @lmarton Marton
almarton@task.com.br
 
This is a typical message returned by the Access OLE DB provider when an incorrect attribute is specified.

Provided the MapPath is correctly returning the full path to your .mdb, this should get you in

strconn="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath("test.mdb") & ";Password=1234"




Jon Hawkins
 
The ODBC driver syntax typically uses PWD as the keyword for a password attribute. I agree OLEDB is generally a better choice whenever it is available.

But we've been looking in the wrong spot I think. Somebody suggested looking at what Server.MapPath( ) returned quite a ways back - or was that another thread?

Server.MapPath
The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

Syntax
Server.MapPath( Path)

Parameters
Path
Specifies the relative or virtual path to map to a physical directory. If Path starts with either a forward (/) or backward slash (\), the MapPath method returns a path as if Path were a full, virtual path. If Path doesn't start with a slash, the MapPath method returns a path relative to the directory of the .asp file being processed.


So... maybe you want that "/" ???
 
Oops, I take that back. I read it wrong.

Still, a good look at the returned string would be worthwhile.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top