|
AnyDAC
|
Fires when an application connects to a DBMS.
Write an OnLogin event handler to take specific actions when an application attempts to connect to a DBMS. When the LoginPrompt property is True, a database login is required. The login dialog and OnLogin event only occur when the LoginPromptproperty is true.
If there is no OnLogin event handler, the current User_Name is read from the Params property or connection definition, and a standard Login dialog box opens. The dialog prompts for a user name, password and other optional parameters, and then uses the values entered by the user to set the User_Name, Password and other optional values in the Params property. These values are then passed to the DBMS.
Applications that provide alternative OnLogin event handlers may set the User_Name, Password and other optional values in AConnectionDef. AConnectionDef is a temporary connection definition and is freed automatically when no longer needed.
property OnLogin: TADConnectionLoginEvent;
Establishing Connection, LoginPrompt, Connected, IADStanConnectionDef
Connecting without login dialog:
procedure TForm1.ADConnection1Login(AConnection: TADCustomConnection; const AConnectionDef: IADStanConnectionDef); begin AConnectionDef.UserName := 'dba'; AConnectionDef.Password := InputBox('Login', 'Please enter DBA password', 'sql'); end; procedure TForm1.Button1Click(ASender: TObject); begin ADConnection1.OnLogin := ADConnection1Login; ADConnection1.LoginPrompt := True; ADConnection1.Connected := True; end;
|
What do you think about this topic? Send feedback!
|