Board index » delphi » TDatabase and Paradox files how?

TDatabase and Paradox files how?

I have a directory C:\Some DB Files\ with Paradox DB files in it. This is
not the BDE default directory for Tables. I can easily connect TTable to
these files, but I can find any combination of how to attach a TDatabase to
them. The TTable has at member TDatabase but it is nil until after the
TTable is activated. I need to use it before the tables are opened.
How the heck do I do this?

One of the things I am trying to do is set the password for a table in the
local dir before the table is opened. The only examples I can find on doing
this use the default BDE database, as soon as I set DatabaseName:='C:\Some
DB Files\'; the hole thing falls apart.

 

Re:TDatabase and Paradox files how?


Re:TDatabase and Paradox files how?


More thoughts on this. I can make this work by using the Database Desktop
Alias manager to add an Alias to the set of default databases. The end user
can not do this though, so the question now becomes...
How do I make and delete Aliases at run time? TDatabase lets me use an
existing one, but not make one.

Thanks.

Quote
God_Of_Pain wrote:
> TDatabase and Paradox files how?

> I have a directory C:\Some DB Files\ with Paradox DB files in it. This is
> not the BDE default directory for Tables. I can easily connect TTable to
> these files, but I can find any combination of how to attach a TDatabase
> to them. The TTable has at member TDatabase but it is nil until after the
> TTable is activated. I need to use it before the tables are opened.
> How the heck do I do this?

> One of the things I am trying to do is set the password for a table in the
> local dir before the table is opened. The only examples I can find on
> doing this use the default BDE database, as soon as I set
> DatabaseName:='C:\Some DB Files\'; the hole thing falls apart.

Re:TDatabase and Paradox files how?


I have made Aliases at run time in the past for MSACCESS DBs

  {set up and create an alias for the test database}
  AliasParams := TStringList.Create;       {allocate memory}
  try
    with AliasParams do
      begin
        Add('DATABASE NAME=' + AFileName);   {database name is set as
the selected filename that contains the whole path}
        Add('OPEN MODE=READ/WRITE');
      end;
    Session.AddAlias('AliasName', 'MSACCESS', AliasParams);   {creates
an alias for the selected database}
  finally
    AliasParams.Free;                      {free memory}
  end;

You should also check to see if the Alias exists first just in case
using

 if Session.IsAlias('AliasName') then try_some_other_name...;

and adjust your name accordingly to one that doesn't exist.

Then you can set the DatabaseName to the Aliasname you created.

   SourceDatabase.DatabaseName := 'AliasName';

Since then, I have found that I can set these parameters straight into
the database component and then I don't have to worry about Aliases.

        SourceDatabase.Params.Clear;   {clear the current database
parameters and load these}
        SourceDatabase.Params.Add('DATABASE NAME=' + AFileName);  
        SourceDatabase.Params.Add('OPEN MODE=READ/WRITE');
        SourceDatabase.Open;    {open the database}

This may catch up to me if I need to change the type of database I am
using from a local ACCESS file to some sort of DB server arrangement
that aliases work better for.  I don't much about that though.  I expect
they recommend Aliases for that reason.

Haven't tried this approach with Paradox yet.  I am not even using a
database component.  Only table and query components.  I only just tried
using Paradox tables in an app last week since not everybody has
MSACCESS and can't deploy an app that uses ACCESS tables without them
having the JET engine.  I wasn't sure what to set for a path to a
paradox database since it is not just a single file like ACCESS.

Let me know how it works for you.

Craig

Note: for the above my Database Component used the MSACCESS driver name

Quote
God_Of_Pain wrote:

> More thoughts on this. I can make this work by using the Database Desktop
> Alias manager to add an Alias to the set of default databases. The end user
> can not do this though, so the question now becomes...
> How do I make and delete Aliases at run time? TDatabase lets me use an
> existing one, but not make one.

> Thanks.

> God_Of_Pain wrote:
> > TDatabase and Paradox files how?

> > I have a directory C:\Some DB Files\ with Paradox DB files in it. This is
> > not the BDE default directory for Tables. I can easily connect TTable to
> > these files, but I can find any combination of how to attach a TDatabase
> > to them. The TTable has at member TDatabase but it is nil until after the
> > TTable is activated. I need to use it before the tables are opened.
> > How the heck do I do this?

> > One of the things I am trying to do is set the password for a table in the
> > local dir before the table is opened. The only examples I can find on
> > doing this use the default BDE database, as soon as I set
> > DatabaseName:='C:\Some DB Files\'; the hole thing falls apart.

Re:TDatabase and Paradox files how?


Re:TDatabase and Paradox files how?


Quote
"God_Of_Pain" <silicontao_...@technologist.com> wrote in message

news:aUsR6.21897$Up2.2685043@news1.telusplanet.net...

Quote
> I have a directory C:\Some DB Files\ with Paradox DB files in it. This is
> not the BDE default directory for Tables. I can easily connect TTable to
> these files, but I can find any combination of how to attach a TDatabase
to
> them. The TTable has at member TDatabase but it is nil until after the
> TTable is activated. I need to use it before the tables are opened.
> How the heck do I do this?

Check the help on tSession, in particular see the GetAliasNames and
GetAliasParams methods.

Other Threads