Mega Code Archive

 
Categories / Delphi / ADO Database
 

How to get infos about aliases

Title: How to get infos about aliases procedure TForm1.FormCreate(Sender: TObject); begin { GetAliasNames Populates a string list with the names of persistent Borland Database Engine (BDE) aliases. } Session.GetAliasNames(ListBox1.Items); end; { Now add an OnClick event for the Listbox: } procedure TForm1.ListBox1Click(Sender: TObject); var tStr: array[0..100] of char; Desc: DBDesc; { The DBDesc structure describes a database, using the following fields: szName DBINAME Specifies the database alias name. szText DBINAME Descriptive text. szPhyName DBIPATH Specifies the physical name/path. szDbType DBINAME Specifies the database type. } begin if ListBox1.Items.Count = 0 then exit; StrPLCopy(tStr, ListBox1.Items.Strings[ListBox1.ItemIndex], High(tStr)); DbiGetDatabaseDesc(tStr, @Desc); with Desc do begin Label1.Caption := StrPas(Desc.szName); Label2.Caption := StrPas(Desc.szPhyName); Label3.Caption := StrPas(Desc.szDbType); Label4.Caption := StrPas(Desc.szText); end; end; // Now add the following to the 'uses' clause at the top of the unit: uses {...,}DB, DBTables, DBITypes, DBIProcs; {********************************************************************} { This Examples is just another approach to get infos about aliases Using 2 component (TListBox) and only use 1 uses clause (dbTables) } uses {...}, DBTables; type TForm1 = class(TForm) ListBox1: TListBox; ListBox2: TListBox; {..} implementation {..} procedure TForm1.FormCreate(Sender: TObject); begin {Get Alias Names} Session.GetAliasNames(ListBox1.Items); end; procedure TForm1.ListBox1Click(Sender: TObject); begin ListBox2.Items.Clear; if ListBox1.Items.Count = 0 then Exit; {Get Alias Driver Names, like Standard, MsAccess, etc} ListBox2.Items.Add('DRIVER=' + Session.GetAliasDriverName(ListBox1.Items.Strings [ListBox1.ItemIndex])); {Get Alias Parameters and add it parameters into listbox2} Session.GetAliasParams(ListBox1.Items.Strings[ListBox1.ItemIndex], ListBox2.Items); end; end.