Changing an alias at run-time 
Author Message
 Changing an alias at run-time

Hello Marc:

You don't need to use an Alias at all.  Since your using Paradox tables you
can:

db.Close;
db.Params.Clear;
db.Params.Add('PATH=C:\APPL\CIE02');
db.Open;

Don't assign an Alias to the TDatabase object.  Set the DriverName property
to STANDARD.  Put a name you make up in the DatabaseName property,  then
assign this name as the Alias to all your Table and Query objects.  Works
great for me!

Good luck!



Quote:
> Hi,

> My application now needs to be multi-compagny.  So i've got a set of
> databases (PARADOX) for each compagnie, separated by directory

> ex:   appl\cie01\client.db ...
>       appl\cie02\client.db ...

> Ok, so i want to be able to change the alias of the database to go from
> compagny 1 to compagny 2.  So i close the database, change it's alias
> (from cie01 to cie02) and open back the database.  Well i cant get acces
> to the database.  I have to close the application and open it back again
> to get acces to the data of cie02).

> Help needed, please

> Marc Morin




Mon, 12 Apr 1999 03:00:00 GMT
 Changing an alias at run-time

Hi,

My application now needs to be multi-compagny.  So i've got a set of
databases (PARADOX) for each compagnie, separated by directory

ex:   appl\cie01\client.db ...
      appl\cie02\client.db ...

Ok, so i want to be able to change the alias of the database to go from
compagny 1 to compagny 2.  So i close the database, change it's alias
(from cie01 to cie02) and open back the database.  Well i cant get acces
to the database.  I have to close the application and open it back again
to get acces to the data of cie02).

Help needed, please

Marc Morin



Mon, 12 Apr 1999 03:00:00 GMT
 Changing an alias at run-time



Quote:
>Hello Marc:

>You don't need to use an Alias at all.  Since your using Paradox tables you
>can:

>db.Close;
>db.Params.Clear;
>db.Params.Add('PATH=C:\APPL\CIE02');
>db.Open;

etc..

Whilst it will work, and Marc may be able to use the solution you
propose, Doug, I would not consider this good design.

You are hard coding a path, which will mean:

a) When the databases are moved to a different drive/directory the
program will need to be amended wherever the path is referenced, and
recompiled.

b) If the product is to be supplied to run on a number of machines, the
databases will be forced to reside where the programmer expects to find
them rather than where the user (customer/client/person who pays your
wages) wants it.

In contrast, using the Alias, will require just ONE change to the BDE
(which could/should be coded as an option within the program) an no
recompile will be required.

--
Tim Stannard -  Ad Hoc Computing, Addlestone, Surrey, UK
                Tel/Fax: 01932 830572  Mob: 0589 918184



Thu, 15 Apr 1999 02:00:00 GMT
 Changing an alias at run-time

Quote:

>Whilst it will work, and Marc may be able to use the solution you
>propose, Doug, I would not consider this good design.
>You are hard coding a path, which will mean:
>a) When the databases are moved to a different drive/directory the
>program will need to be amended wherever the path is referenced, and
>recompiled.

I don't think the gentlemen meant it as a constant expression.  A variable will
do just as nicely.  However, in the Databasename property of the TTable object,
it reads that you can place a BDE Alias, or a literal path, to the table in
question.

Quote:
>b) If the product is to be supplied to run on a number of machines, the
>databases will be forced to reside where the programmer expects to find
>them rather than where the user (customer/client/person who pays your
>wages) wants it.

If you are using Delphi 2.0 you can use a data module, scroll through all the
TTable and TQuery objects and assign their Databasename properties to whatever
Alias / path variable you wish.

Additionally, you can use the TSession object's method call AddAlias or
AddAliasStandard, either will create a permanent or temporary alias, based upon
TSession's ConfigMode property.  Once you have the name of the alias, you can
perform the mechanism in the paragraph above to set the TTable/TQuery objects
appropriately.

Quote:
>In contrast, using the Alias, will require just ONE change to the BDE
>(which could/should be coded as an option within the program) an no
>recompile will be required.

I concur with this statment.  It depends upon what / who you are doing this for.

Mike Johnson
Software Engineer
State Of The Art, Inc.
--------------------------




Mon, 26 Apr 1999 03:00:00 GMT
 
 [ 4 post ] 

 Relevant Pages 

1. Change BDE alias in run-time ?

2. Change BDE alias in run-time ?

3. Change/Create Alias at Runtime

4. changing alias in run-time..no effect ?

5. Changing the location of alias at run-time

6. Change path of BDE-alias at run-time

7. Changing/adding DB-Aliases run-time

8. Adding alias to BDE at run time

9. Add an alias at run-time

10. Changing Alias Directory at runtime?

11. Help: Change Alias in BDE at runtime with Delphi 1.0

12. Creating alias & ODBC Driver in Run-Time


 
Powered by phpBB® Forum Software