TTdbDatabase.OnPassword
TTdbDatabase

Occurs when an application attempts to open a protected TurboDB table for the first time.

TTdbPasswordEvent = procedure(Sender: TObject; const TableName: stringvar Password: stringvar Key: LongInt; var Retry: Boolean) of object;
property OnPassword: TTdbPasswordEvent;

Description
Write an OnPassword event handler to take specific action when an application attempts to open a password-protected or encrypted TurboDB table for the first time. To gain access to the TurboDB table, the event handler must set the parameters to a password and key. Use Retry to conditionally finalize opening the table. If Retry is set to True, opening the table is tried with the new password and key provided in the arguments. If set to False, the attempt to open the table is abandoned.

Note
If an OnPassword event handler does not exist, but TurboDB reports insufficient access rights, an exception is raised.

Example
The following example shows a typical event handler and the source code for opening the table.

procedure TForm1.Password(Sender: TObject; const TableName: stringvar Password: stringvar Key: LongInt; var Retry: Boolean); 
begin
   // Assuming the table is password-protected but not encrypted
   Password := InputBox('Enter password', 'Password:', '');
   Retry := (Password > '');
end;

procedure TForm1.OpenTableBtnClick(Sender: TObject);
begin
   Database.OnPassword := Password;
   try
      Table1.Open;
   except
      if not Table1.Active then begin
         ShowMessage('Could not open table');
         Application.Terminate;
    end;
  end;
end;