problem connecting to ADO programmatically



I have taken the connection string created using the MS wizard, and
broken it into a series of constants, so I can replace the file path
dynamically. When I attempt to do this, I get the "Could not find
installable ISAM" error message. My code:

const
ADOProvider = 'Provider=Microsoft.Jet.OLEDB.4.0;';
ADOPassword = 'Password="";';
ADOUserID = 'User ID=Admin;';
ADODataSource = 'Data Source=I:\Development\CAP\CapWatch\CAPWATCH 24
MAY 07.MDB;';
ADOMode = 'Mode=Share Deny None;';
ADOExtProp = 'Extended Properties="";';
ADOJetTail = 'Jet OLEDB:System database="";OLEDB:Registry Path="";' +
'Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=4;' +
'Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global
Partial Bulk Ops=2;' +
'Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New
Database Password="";' +
'Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt
Database=False;' +
'Jet OLEDB:Don''t Copy Locale on Compact=False;' +
'Jet OLEDB:Compact Without Replica Repair=False;Jet
OLEDB:SFP=False';

function TDMCapWatch.ConnectToDB(DBFile: string): Boolean;
var
ConnStr: string;
target : string;
begin
Result := false;
if not FileExists(DBFile) then Exit;
ADOConnCAPWatch.Close;
ConnStr := ADOProvider + ADOPassword + ADOUserID;
target := 'DataSource=' + DBFile + ';';
ConnStr := ConnStr + target + ADOMode + ADOExtProp + ADOJetTail;
ADOConnCAPWatch.ConnectionString := WideString(ConnStr);
ADOConnCAPWatch.Open;
Result := ADOConnCAPWatch.Connected;
end;

If I comment out the assignment to ADOConnCAPWatch.ConnectionString,
there is no error. I have tried commenting out parts of the tail
strings, finally reaching this:

ConnStr := ADOProvider + ADOPassword + ADOUserID;
target := 'DataSource=' + DBFile + ';';
ConnStr := ConnStr + target; // + ADOMode + ADOExtProp + ADOJetTail;
ADOConnCAPWatch.ConnectionString := WideString(ConnStr);
ADOConnCAPWatch.Open;
Result := ADOConnCAPWatch.Connected;

I still get the error. Any suggestions?

--

Bill
.



Relevant Pages

  • Multipart connectionstring question
    ... I’ve got an asp.net site that contains an access database. ... running the same app both on my machine and my host without making changes. ... How could one even use a server.mappath with a database connection string? ...
    (microsoft.public.dotnet.general)
  • Installer - Custom Textboxes in UI problem
    ... void Install function. ... I've tested it by writing the string out to a text file ... put the connection string and I intend to test the db connectivity and write ... throw new InstallException("The database conection information is not ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Accessing mdb file via VB code
    ... None of the previous installs re-registers etc worked but I got it fixed ... If any of you know why my string would not work, ... You need a connection string like: ... Some people report it as happening to an entire new suite of boxes. ...
    (microsoft.public.vb.general.discussion)
  • Re: EXEC master..xp_cmdshell Prevention
    ... way to significantly reduce vulnerabilities around dynamic string execution. ... > I found that my web application did use a connection string in a file ... I have created a new login account ...
    (microsoft.public.sqlserver.security)
  • Re: EXEC master..xp_cmdshell Prevention
    ... I take it you're using string concatenation to build your sql statements. ... Next item -- using dbo for a web application's login is dangerous, ... sounds as though either a) your connection string isn't what you think it is ...
    (microsoft.public.sqlserver.security)