Bde.DBTables.TSession.GetPassword

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function GetPassword: Boolean;

C++

bool __fastcall GetPassword();

Properties

Type Visibility Source Unit Parent
function public
Bde.DBTables.pas
Bde.DBTables.hpp
Bde.DBTables TSession

Description

Invokes the OnPassword event handler for the session or displays the default password dialog box.

Call GetPassword to invoke the OnPassword event handler for the session and handle response logic when an application is working with password-protected Paradox files. If an OnPassword event handler is not defined, GetPassword displays the default password dialog box.

An application can use the return value of GetPassword to control program logic. GetPassword returns true if a user chooses OK, or false if the user chooses Cancel.



var
rslt: Boolean;
begin
rslt := Session.GetPassword;
try
if rslt then
Table1.Open
else
ShowMessage('No password given');
except
ShowMessage('Could not open table!');
end;
ifnot Table1.Active then
Application.Terminate;
end;



void __fastcall TForm1::OpenTableButtonClick(TObject *Sender)
{
bool rslt = Session->GetPassword();
try
{
if (rslt)
Table1->Open();
else
ShowMessage("No password given");
}
catch (...)
{
ShowMessage("Could not open table!");
}
if (!Table1->Active)
Application.Terminate();
}



See Also