Board index » delphi » Looking for a component that returns Path of the BDE alias

Looking for a component that returns Path of the BDE alias

Looking for a component that returns Path of the BDE alias.  (Interbase)
I'm using a TDatabase with an assign alias.  I want to be able to see what
the path to the database is.

Paul Klomp
p...@rxcmpd.com

 

Re:Looking for a component that returns Path of the BDE alias


Try this function:

function GetPathFromAlias(alias: String): String;
var BDEParams: TStringList;
begin
  BDEParams := TStringList.Create;
  try
    Session.GetAliasParams(alias, BDEParams);
    Result := BDEParams.Values['SERVER NAME'];
  finally
    BDEParams.Free
  end;
end;

Thomas Steinmaurer
IB LogManager - The Logging Tool for Interbase
http://www.equitania.de/interbase/iblogmanager/start.htm (German)
http://www.equitania.de/interbase/iblogmanager/default.htm (English)
E-Mail:     mailto:iblogmana...@aon.at

"Paul Klomp" <p...@rxcmpd.com> schrieb im Newsbeitrag
news:95mtge$mc7@bornews.inprise.com...

Quote
> Looking for a component that returns Path of the BDE alias.  (Interbase)
> I'm using a TDatabase with an assign alias.  I want to be able to see what
> the path to the database is.

> Paul Klomp
> p...@rxcmpd.com

Re:Looking for a component that returns Path of the BDE alias


Try the following.
-----------------------------------------------------
Here are three ways to get the path associated with an alias. No1 is for
permanent BDE aliases only. No2 works on BDE and local aliases and No3 works
with BDE and local aliases as well as with tables with a hardcoded path,
using DBI calls.
function GetDBPath1(AliasName: string): TFileName;
var ParamList: TStringList;
begin
  ParamList := TStringList.Create;
  with Session do
  try
    GetAliasParams(AliasName,ParamList);
    Result := UpperCase(ParamList.Values['PATH'])+'\';
  finally
    Paramlist.Free;
  end;
end;

function GetDBPath2(AliasName: string): TFileName;
var ParamList: TStringList;
    i: integer;
begin
  ParamList := TStringList.Create;
  with Session do
  try try
      GetAliasParams(AliasName,ParamList);
    except
      for i:=0 to pred(DatabaseCount) do
        if (Databases[i].DatabaseName = AliasName) then
          ParamList.Assign(Databases[i].Params);
    end;
    Result := UpperCase(ParamList.Values['PATH'])+'\';
  finally
    Paramlist.Free;
  end;
end;

function GetDBPath3(ATable: TTable): TFileName;
var TblProps: CURProps;
    pTblName, pFullName: DBITblName;
begin
  with ATable do
  begin
    AnsiToNative(Locale, TableName, pTblName, 255);
    Check(DBIGetCursorProps(Handle, TblProps));
    Check(DBIFormFullName(DBHandle,
                          pTblName,
                          TblProps.szTableType,
                          pFullName));
    Result := ExtractFilePath(StrPas(pFullName));
  end;
end;

--
Bill

Other Threads