Board index » delphi » Filling TDatabase.Params at runtime

Filling TDatabase.Params at runtime

At designtime I can double-click a TDatabase and then click the
Defaults button to fill the Params property with the parameters from
the alias specified in the AliasName property. How do I accomplish
this at run-time?

CUL8R dude!                       \|/
                                  @ @
Jens  +-----------------------oOO-(_)-OOo-----------------------+
      | Internet   jb...@image.dk     Fax     +45 - 3537 - 7006 |
      +---------------------------------------------------------+

 

Re:Filling TDatabase.Params at runtime


Here is a method I use: Pass it a Server Name, User Name, and Password

{------------------------------------------------------------------------------}
function TAdmin_DataModule.Connect_Database(aServer, aUserName,
aPassword : string; aDatabase : TDatabase) : Boolean;
var
 TmpStrList : TStringList;
begin
 TmpStrList := nil;
 Result := True;
   try
    TmpStrList := TStringList.Create;
    TmpStrList.Add('SERVER NAME=' + aServer);
    TmpStrList.Add('USER NAME=' + aUserName);
    TmpStrList.Add('PASSWORD=' + '');
    aDatabase.Params.Assign(TmpStrList);
   finally
    try
     aDatabase.Connected := True;
     Result := aDatabase.Connected;
     TmpStrList.Free;
    except
     Result := False;
     aDatabase.Connected := False;
     TmpStrList.Free;
    end; {try except}
   end;

end;

Quote
Jens Bang wrote:

> At designtime I can double-click a TDatabase and then click the
> Defaults button to fill the Params property with the parameters from
> the alias specified in the AliasName property. How do I accomplish
> this at run-time?

> CUL8R dude!                       \|/
>                                   @ @
> Jens  +-----------------------oOO-(_)-OOo-----------------------+
>       | Internet   jb...@image.dk     Fax     +45 - 3537 - 7006 |
>       +---------------------------------------------------------+

--
                   \|||/
                   /'^'\
                  ( 0 0 )
--------------oOOO--(_)--OOOo--------------
. Reid Roman                              .
. Delphi Programmer / Analyst             .
. TVisualBasic:=class(None);              .
. May the Source be With You              .
-------------------------------------------
. Auto-By-Tel (http://www.autobytel.com)  .
. Irvine, CA U.S.A                        .
. E-Mail : rkroman (at) pacbell (dot) net .
. or reidr (at) autobytel (dot) com       .
-------------------------------------------

Re:Filling TDatabase.Params at runtime


On Wed, 19 Aug 1998 06:35:42 -0700, Reid Roman <rkro...@pacbell.net>
wrote:

Quote
>Here is a method I use: Pass it a Server Name, User Name, and Password

Thanks, but what I need is a way to fill the Params property with the
actual parameters defined in a specific alias, with out hardcoding
them into the program. The Alias may change from customer to customer,
and I don't want to have to recompile for every new customer.

CUL8R dude!                       \|/
                                  @ @
Jens  +-----------------------oOO-(_)-OOo-----------------------+
      | Internet   jb...@image.dk     Fax     +45 - 3537 - 7006 |
      +---------------------------------------------------------+

Re:Filling TDatabase.Params at runtime


Put it on the INI file. If empty, (first time) ask the user, otherwise, let
it rip.
Quote
Jens Bang wrote in message <35dae41d.61671...@news.image.dk>...
>On Wed, 19 Aug 1998 06:35:42 -0700, Reid Roman <rkro...@pacbell.net>
>wrote:

>>Here is a method I use: Pass it a Server Name, User Name, and Password

>Thanks, but what I need is a way to fill the Params property with the
>actual parameters defined in a specific alias, with out hardcoding
>them into the program. The Alias may change from customer to customer,
>and I don't want to have to recompile for every new customer.

>CUL8R dude!                       \|/
>                                  @ @
>Jens  +-----------------------oOO-(_)-OOo-----------------------+
>      | Internet   jb...@image.dk     Fax     +45 - 3537 - 7006 |
>      +---------------------------------------------------------+

Re:Filling TDatabase.Params at runtime


There are components to do some of this at the Delphi Super Page.  I
use  the AliasEditor component by Glenn Davies.  This way you can find
out what is available, and if necessary, create the BDE stuff yourself.

Oliver

Quote
Jens Bang wrote:

> On Wed, 19 Aug 1998 06:35:42 -0700, Reid Roman <rkro...@pacbell.net>
> wrote:

> >Here is a method I use: Pass it a Server Name, User Name, and Password

> Thanks, but what I need is a way to fill the Params property with the
> actual parameters defined in a specific alias, with out hardcoding
> them into the program. The Alias may change from customer to customer,
> and I don't want to have to recompile for every new customer.

> CUL8R dude!                       \|/
>                                   @ @
> Jens  +-----------------------oOO-(_)-OOo-----------------------+
>       | Internet   jb...@image.dk     Fax     +45 - 3537 - 7006 |
>       +---------------------------------------------------------+

--
Oliver
oli...@zip.com.au
Sashalom Pty Ltd
Ph: +61-2-9283-1377 (w) 9675-1769 (h) 0411 754 414 (mob)

Re:Filling TDatabase.Params at runtime


Quote
On Wed, 19 Aug 1998 19:25:48 -0500, "PINKO" <PI...@VATICAN.GOV> wrote:
>Put it on the INI file. If empty, (first time) ask the user, otherwise, let
>it rip.

If my users were to enter the same information twice it is too much of
a chance that they will enter incorrect info.

But worse: What if the alias changes?

CUL8R dude!                       \|/
                                  @ @
Jens  +-----------------------oOO-(_)-OOo-----------------------+
      | Internet   jb...@image.dk     Fax     +45 - 3537 - 7006 |
      +---------------------------------------------------------+

Other Threads