Hi Steve,

Steve Bowker wrote:
> Hi,
> I'm having a problem with setting ADO properties at run-time compared to 
> design time.
>  
> Design-time (this works) I have ...
>   
> DataSource1.DataSet := DataSource1;
>  
> ADOTable1.Active := True;
> ADOTable1.Connection := ADOConnection1;
> ADOTable1.ConnectionString is blank
>  
> ADOConnection1.Connected := True;
> ADOConnection1.connectionString := standard Microsoft.Jet.OLEDB.4.0 string
>   

Ok, this is a little reverse really.  You want to setup the connection 
first, and make sure it is connected before you set it in the ADOTable, 
and open the table afterwards, so something more like:

ADOConnection1.ConnectionString := 'Blah';
ADOConnection1.Connected := True;

ADOTable1.Connection := ADOConnection1;
ADOTable1.Active := True;

However, on making the table active it will try to make the underlying 
Connection Connected anyway, so you might not necessarily need that 
Connected line, but I prefer to have it myself.  :)


> So when I run the app, it runs fine from my own PC displaying info in a 
> DBGrid.
>  
> But, I want to change the connection string so that at run time it gets the 
> database path from the users PC and builds the connection string.
>  
> Does the connection string have to be set for all of these ADO components, or 
> just the ADOConnection?  and in what sequence in the code?
> It's just that if I manually set the ADO components to not active, or not 
> connected, and then try to set the ADOConnection string at FormCreate event, 
> I get the following error...
>  
> Project raised exception class EOleException with message 'could not find 
> installable ISAM. Process stopped. Use Step or Run to continue.
>
> NB, I'm using Delphi 5 and an Access database , and the 
> ADOConnection1.Provider := Microsoft.Jet.OLEDB.4.0


I must admit, I always preferred to build an ADO Connection file on the 
client, and refer to that file in code, so that I could change the ADO 
Connection settings without affecting the way my application would load it.

// You could change this to be dynamically creating the path of course.
ADOConnection1.ConnectionString = 'File Name=C:\Path\To\Database.UDL;';
ADOConnection1.Connected := True;

This is all the code you would need then, no need to specify further 
parameters for the connection, as this will be configured and controlled 
by the UDL file.

Right click in a directory somewhere, and create a new text file, and 
then rename it to Database.UDL and then double-click on the UDL file.

It will fire up the Data Link Properties editor, which you can use to 
configure your ADO Connection how ever you want.  This way all you have 
to do to change the location/database, or whatever, is just simply edit 
this file to make your changes, and the application will always get the 
contents of that file when your code re-sets up the connection component.

I hope this is of some help to you.


Kind regards,


Scott Price :)
_______________________________________________
Delphi-DB mailing list
[email protected]
http://lists.elists.org/cgi-bin/mailman/listinfo/delphi-db

Reply via email to