Add a password in a Paradox table at runtime  

Send By: Radikal (Q3 Team)
Web : http://www.q3.nu
Email: radikal@q3.nu
Date: 15/02/00

Tip accessed 461 times

 


There is a tip in which we indicate as protecting with password a Paradox table by means of the Database Desktop.
Here you have the form of making it by means of code:

  • Add DBIProcs and DBITypes in the uses of your form


     procedure TForm1.Button1Click(Sender: TObject);
    
     procedure PonClave(Const ADatabase, ATable:string; Clave:DbiName);
     var
       ADB       :TDataBase;
       SaveKC    : Boolean;
       PdxStruct : CRTblDesc;
     begin
    
     with TTable.Create(nil) do
       try
        DatabaseName := ADatabase;
         TableName := ATable;
         Exclusive := True;
         Open;
         ADB := DAtabase;
         SaveKC := ADB.KeepConnection;
         ADB.KeepConnection := True;
         try
          Close;
           FillChar(PdxStruct,SizeOF(PdxStruct),0);
           StrPCopy(PdxStruct.szTblName,ATable);
           PdxStruct.bPack := False;
           PdxStruct.bProtected:= TRUE;
           {Esta es la clave que se pondrá en la tabla}
           PdxStruct.szPassword:=Clave;
           Check(DbiDoRestructure(ADB.Handle,1,
             @PdxStruct,nil,nil,nil,False));
         finally
          ADB.KeepConnection := SaveKC;
         end;
       finally
        Free;
       end;
     end;
    
     begin
       PonClave('DBDEMOS','BIOLIFE.DB','MiPassword');
     end;
    




    Updated at 15/02/2000 (Uses missing...)