delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (4)


Search and Create a new Alias with BDE calls.Go to Enrique Ortuño's websiteFormat this article printer-friendly!Bookmark function is only available for registered users!
Product:
Delphi 3.x (or higher)
Category:
BDE
Skill Level:
Scoring:
Last Update:
05/25/2000
Search Keys:
delphi delphi3000 article borland vcl code-snippet alias BDE DbiOpenDatabaseList
Times Scored:
7
Visits:
7010
Uploader: Enrique Ortuño
Company: Tecnocrata & Consulting
Reference: iTerCom
 
Question/Problem/Abstract:
Search and Create a new Alias with BDE calls.
Answer:



To create a temporary alias has been topic of other article similar ( http://www.delphi3000.com/article.asp?id=913 ) of Dmitri Papichev, but the difference of the previous, that here I make direct calls to the BDE and I seek an equal alias before creating one new, therefore maybe interest to you.

1. Declare BDE, Dbtables  in USES section.
2. This set of sentences can be put on the part of initialization of the code of the form or maybe of a DataModule.


Var
AliasFound: Boolean;
TmpCursor: hDBICur;
Rslt: DBIResult;
Database: DBDesc;

Begin
Check(DbiInit(nil));
try
Check(DbiOpenDatabaseList(TmpCursor));
AliasFound := False;
  repeat
    {Get a DBDesc record for the next alias}
    rslt:= DbiGetNextRecord(TmpCursor, dbiNOLOCK, @Database, nil);
    if (rslt <> DBIERR_EOF) then
      if StrPas(Database.szName) = 'MyAlias' then
        begin
          {The alias MyAlias already exists}
          AliasFound := True;
          Break
        end;
  until rslt <> DBIERR_NONE;
  Check(DbiCloseCursor(TmpCursor));
  if not AliasFound then
    {If the alias was not found, add it to IDAPI.CFG}
    Check(DbiAddAlias(nil,PChar('MyAlias'),nil,
       PChar('PATH:'+ExtractFilePath(Application.ExeName)),True))
finally
  DbiExit;
end;
end;


Regards.






Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
Unable to create a permanent alias
    Vinh Lam (Dec 11 2000 1:17PM)

I try your code with no error.  However, the new alias is not there.
I wrote a sample program to create a permanent alias using your code but was unable to make it work.  I am using Delphi 5.
Where does it go wrong?
Respond

RE: Unable to create a permanent alias
Enrique Ortuño (Dec 11 2000 1:44PM)

Humm I receive the same error I think this work only for D3 and D4.
Respond

Link / Reference / See also...
    PEPS ^^ (May 25 2000 12:58PM)

thanks for the link to the article 913 !

regards
bernhard a.
Respond

RE: Link / Reference / See also...
vit lucio (Jan 13 2007 5:25PM)

whit bde alias is databasepath
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


   


  Community Ad of
S. Carter
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)