Board index » delphi » Extracting path from BDE alias or database?

Extracting path from BDE alias or database?

Can anyone please tell me if there is a way to extract the file path
using the BDE alias or databasename?
 

Re:Extracting path from BDE alias or database?


This is what I did with a table in the DBDEMOS alias:

 Table1.open;
   showmessage(Session.PrivateDir);

Hope that helps

********************************
Michael Glatz
glatzfa...@aol.com
mgl...@briefcase.com

Re:Extracting path from BDE alias or database?


Quote
Phil Smith wrote:
> Can anyone please tell me if there is a way to extract the file path
> using the BDE alias or databasename?

Phil,

Function  GetPathFromAlias(Alias:string):string;
var
   x:TStringList;
   i:integer;
begin
     result:='';
     if (Session <> nil) then begin
       x:=TStringList.Create;
       try
          Session.GetAliasParams(alias,x);
          for i:=0 to pred(x.count) do begin
            if (Copy(x.strings[i],1,5) = 'PATH=' )then begin
              Result:=Copy(x.strings[i],6,255);
            end;
          end;
       finally
          x.free;
       end;
     end;
end;

Hope this helps (it works for me!),
Frank

Re:Extracting path from BDE alias or database?


Quote
Phil Smith wrote:
> Can anyone please tell me if there is a way to extract the file path
> using the BDE alias or databasename?

Phil,

Function  GetPathFromAlias(Alias:string):string;
var
   x:TStringList;
   i:integer;
begin
     result:='';
     if (Session <> nil) then begin
       x:=TStringList.Create;
       try
          Session.GetAliasParams(alias,x);
          for i:=0 to pred(x.count) do begin
            if (Copy(x.strings[i],1,5) = 'PATH=' )then begin
              Result:=Copy(x.strings[i],6,255);
            end;
          end;
       finally
          x.free;
       end;
     end;
end;

Hope this helps (it works for me!),
Frank

Re:Extracting path from BDE alias or database?


Quote
Phil Smith wrote:
> Can anyone please tell me if there is a way to extract the file path
> using the BDE alias or databasename?

Phil,

Function  GetPathFromAlias(Alias:string):string;
var
   x:TStringList;
   i:integer;
begin
     result:='';
     if (Session <> nil) then begin
       x:=TStringList.Create;
       try
          Session.GetAliasParams(alias,x);
          for i:=0 to pred(x.count) do begin
            if (Copy(x.strings[i],1,5) = 'PATH=' )then begin
              Result:=Copy(x.strings[i],6,255);
            end;
          end;
       finally
          x.free;
       end;
     end;
end;

Hope this helps (it works for me!),
Frank

Re:Extracting path from BDE alias or database?


try this function. I've used it in D3.
David

function GetDataBaseDir(const Alias : string): String;
var
  dbDes: DBDesc;
begin
  Check(DbiGetDatabaseDesc(PChar(Alias), @dbDes));
  with dbDes do
    Result := szPhyName;
end; // end of GetDataBaseDir

Quote
Phil Smith wrote in message <6uam1o$es...@hermes.is.co.za>...
>Can anyone please tell me if there is a way to extract the file path
>using the BDE alias or databasename?

Re:Extracting path from BDE alias or database?


Glatzfamly,

How can I define the path for an alias.
Example. I have a project that work with various subdirectory and I use
an alias. So, I need change the paht of the alias to change the
database.

Thanks,

Rogerio Cardoso
tasii...@zaz.com.br

Glatzfamly escreveu:

Quote
> This is what I did with a table in the DBDEMOS alias:

>  Table1.open;
>    showmessage(Session.PrivateDir);

> Hope that helps

> ********************************
> Michael Glatz
> glatzfa...@aol.com
> mgl...@briefcase.com

Other Threads