Board index » delphi » Create a Permanent New Alias

Create a Permanent New Alias

I am using dbiaddalias with the last parameter as TRUE which
should cause the alias to be stored in the configuration file
(as I read it anyway). It only seems to be session specific.
I am using D4 with BDE 5.01. What am I doing wrong?

Also, while I have your attention (and knowing this is prob-
ably a really stupid question), how do I capture the dbiresult
return value of dbierr_namenotunique. I can capture the
e.message = 'Name not uniq...' but somehow I think there must
be a better way, and (as of right now), I am not finding it.

Thanks.

 

Re:Create a Permanent New Alias


On 13 Jul 1999 00:14:58 GMT, "John C. Bell III" <jcb...@us.net> wrote:

Quote
>I am using dbiaddalias with the last parameter as TRUE which
>should cause the alias to be stored in the configuration file
>(as I read it anyway). It only seems to be session specific.
>I am using D4 with BDE 5.01. What am I doing wrong?

You have to additionally save to the configuration file:
    Session.SaveConfigFile;

Quote
>Also, while I have your attention (and knowing this is prob-
>ably a really stupid question), how do I capture the dbiresult
>return value of dbierr_namenotunique. I can capture the
>e.message = 'Name not uniq...' but somehow I think there must
>be a better way, and (as of right now), I am not finding it.

You're probably calling DbiAddAlias() like this now:
   Check(DbiAddAlias(...

Change that to:

   ErrCode: DbiResult;

   ErrCode := DbiAddAlias(...
   if ErrCode = DBIERR_NAMENOTUNIQUE then
   begin
       ...
   end else
       Check(ErrCode);

Jan

Re:Create a Permanent New Alias


Thank you. Next question is, if I need to use SaveConfigFile,
then what is the difference between True & False for the last
parameter in dbiaddalias? I guess I am asking whether you can
have an alias for a session which does not show up in the
configuration file?

Jan Sprengers <j...@nospamplease.adm2000.be> wrote in article
<378af72c.496975...@forums.inprise.com>...

Quote
> On 13 Jul 1999 00:14:58 GMT, "John C. Bell III" <jcb...@us.net> wrote:

> >I am using dbiaddalias with the last parameter as TRUE which
> >should cause the alias to be stored in the configuration file
> >(as I read it anyway). It only seems to be session specific.
> >I am using D4 with BDE 5.01. What am I doing wrong?

> You have to additionally save to the configuration file:
>     Session.SaveConfigFile;

> >Also, while I have your attention (and knowing this is prob-
> >ably a really stupid question), how do I capture the dbiresult
> >return value of dbierr_namenotunique. I can capture the
> >e.message = 'Name not uniq...' but somehow I think there must
> >be a better way, and (as of right now), I am not finding it.

> You're probably calling DbiAddAlias() like this now:
>    Check(DbiAddAlias(...

> Change that to:

>    ErrCode: DbiResult;

>    ErrCode := DbiAddAlias(...
>    if ErrCode = DBIERR_NAMENOTUNIQUE then
>    begin
>        ...
>    end else
>        Check(ErrCode);

> Jan

Re:Create a Permanent New Alias


On 13 Jul 1999 09:36:03 GMT, "John C. Bell III" <jcb...@us.net> wrote:

Quote
>Thank you. Next question is, if I need to use SaveConfigFile,
>then what is the difference between True & False for the last
>parameter in dbiaddalias?

The problem is that BDE help is not complete in this area.  E.g.
TSession.SaveConfigFile calls DbiCfgSave which is not documented.
Only experimentation can tell if this bPersistent flag still makes a
difference  (I've never had the need to test this out for myself).

Quote
> I guess I am asking whether you can
>have an alias for a session which does not show up in the
>configuration file?

If you don't save it, it will be a temporary alias.

Jan

Re:Create a Permanent New Alias


Is it better to use session.addalias or dbiaddalias?

I also am running into a problem with dbiaddalias where the
alias is added but the path is shown without an entry and no
driver is shown. Then when I try dbideletealias, I get a return
of no error (which means it was successful according to the
documentation) but... it's lying to me, it's still there! Any
more thoughts?

Thank you again for your time.

Jan Sprengers <j...@nospamplease.adm2000.be> wrote in article
<378b5574.521110...@forums.inprise.com>...

Quote
> On 13 Jul 1999 09:36:03 GMT, "John C. Bell III" <jcb...@us.net> wrote:

> >Thank you. Next question is, if I need to use SaveConfigFile,
> >then what is the difference between True & False for the last
> >parameter in dbiaddalias?

> The problem is that BDE help is not complete in this area.  E.g.
> TSession.SaveConfigFile calls DbiCfgSave which is not documented.
> Only experimentation can tell if this bPersistent flag still makes a
> difference  (I've never had the need to test this out for myself).

> > I guess I am asking whether you can
> >have an alias for a session which does not show up in the
> >configuration file?

> If you don't save it, it will be a temporary alias.

> Jan

Re:Create a Permanent New Alias


On 15 Jul 1999 03:48:06 GMT, "John C. Bell III" <jcb...@us.net> wrote:

Quote
>Is it better to use session.addalias or dbiaddalias?

It is easier to use TSession.AddAlias.  But you can only check on
failure then with try-except.  Or you can avoid failure:

    if Session.IsAlias(MyAlias) then
       Session.DeleteAlias(MyAlias);
    Session.AddStandardAlias(MyAlias, DataPath, 'Paradox');
    Session.SaveConfigFile;

Quote
>I also am running into a problem with dbiaddalias where the
>alias is added but the path is shown without an entry and no
>driver is shown. Then when I try dbideletealias, I get a return
>of no error (which means it was successful according to the
>documentation) but... it's lying to me, it's still there! Any
>more thoughts?

No.  I'd have to see your code for this.
But you might want to start another thread for this, because I'm not
going to be able to visit this forum for a couple of days.

Jan

Other Threads