Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Dejan Dozet
Dejan Dozet

Posted on

TADOConnection: Proper Use of LoginPrompt

When using TADOConnection in Delphi, you may want to control when the login dialog appears. Setting LoginPrompt to True triggers the prompt each time a connection is attempted, which is useful if credentials aren’t stored in the connection string.

Example Usage

Here's an example illustrating conditional use of LoginPrompt:

procedure TfrmMain.FormShow(Sender: TObject);var  i: integer;begin  con1.Provider := 'SQLOLEDB.1';  con1.Properties['Application Name'].Value := Application.Title;  with TIniFile.Create(ExtractFileDir(ParamStr(0)) + '\setup.ini') do  begin    con1.Properties['Initial Catalog'].Value := ReadString('database', 'Initial Catalog', '');    con1.Properties['Data Source'].Value := ReadString('database', 'Data Source', '');    if ReadBool('database', 'Integrated Security', false ) then    begin      con1.Properties['Integrated Security'].Value := 'SSPI';      con1.Properties['Persist Security Info'].Value := 'False';      con1.LoginPrompt := False;    end    else    begin      con1.Properties['Persist Security Info'].Value := 'True';      con1.LoginPrompt := true;    end;  end;end;procedure TfrmMain.con1Login(Sender: TObject; Username, Password: string);begin  con1.Properties['User ID'].Value := Username;  con1.Properties['Password'].Value := Password;end;
Enter fullscreen modeExit fullscreen mode

In this case, the prompt appears only when credentials are missing, providing flexibility and enhancing security.

Tips

  1. Conditionally prompt: Use LoginPrompt based on your security needs.
  2. Avoid hardcoded credentials: Protect sensitive data when LoginPrompt is enabled.
  3. Consistent user experience: Keep the prompt behavior uniform across your app.

Final Thoughts

Using LoginPrompt wisely can simplify the user experience while ensuring secure access.

For more details about it and much more similar posts, check this page on my blog:TADOConnection: Correct Way to Use LoginPrompt.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

  • Location
    Tomislavci, Serbia
  • Joined

Trending onDEV CommunityHot

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp