DelphiFAQ Home Search:
General :: Programming :: Delphi :: Database
Database development with Delphi. Includes issues with BDE, ADO and InterBase.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Only the 40 most recently viewed articles are shown.
You can see the full list here.

Featured Article

Assign a password to a Paradox table

To assign a password to a Paradox table, use the following unit and call function TablePasswort like this:

uses Unit2;
// ..
TablePasswort (Table1, 'secret');

unit Unit2;
 
 interface
 
 uses
   BDE, SysUtils, DBTables, Windows;
 
 function TablePasswort(var table: TTable; password: String) : Boolean;
 
 implementation
 
 function StrToOem(const AnsiStr: String) : String;
 begin
   SetLength(result, Length(AnsiStr));
   if Length(result)>0 then
     CharToOem(PChar(AnsiStr), PChar(result))
 end;
 
 
 function TablePasswort(var table: ttable; password: String) : Boolean;
 var
   pTblDesc : pCRTblDesc;
   hDb      : hDBIDb;
 begin 
   result := false; 
   with table do 
   begin 
     if Active and (not Exclusive) then 
       Close; 
     if (not Exclusive) then 
       Exclusive := true; 
     if (not Active) then 
       Open; 
     hDb := DBHandle; 
     Close
   end; 
   GetMem(pTblDesc, sizeof(CRTblDesc)); 
   FillChar(pTblDesc^, sizeof(CRTblDesc), 0); 
   with pTblDesc^ do 
   begin 
     StrPCopy(szTblName, StrToOem(table.tablename)); 
     szTblType := szParadox; 
     StrPCopy(szPassword, StrToOem(password)); 
     bPack := true; 
     bProtected := true
   end; 
   if DbiDoRestructure(hDb, 1, pTblDesc, nil, nil, nil, false)<>DBIERR_NONE then 
     exit; 
   if pTblDesc<>nil then 
     FreeMem(pTblDesc, sizeof(CRTblDesc)); 
   result := true
 end; 
 
 
 end.
 

Generated 4:01:06 on Aug 12, 2020