FireDac连接问题

时间:2015-08-14 09:32:14

标签: delphi firedac

我在这里使用了一个例子:

establishing connection

这样做了:

procedure TDataModule2.DataModuleCreate(Sender: TObject);
begin
with FDGUIxLoginDialog1.VisibleItems do begin
  Clear;
  Add('Server=Strežnik');
  Add('User_name=Uporabnik');
  Add('Password=Geslo');
  Add('Database=Baza');
end;
try
FDConnection1.Connected := True;
except
  on E: EAbort do
  application.terminate;   // user pressed Cancel button in Login dialog

  on E:EFDDBEngineException do
    case E.Kind of
    ekUserPwdInvalid: ; // user name or password are incorrect
    //ekUserPwdExpired: ; // user password is expired
    ekServerGone: ;     // DBMS is not accessible due to some reason
    else
                 // other issues
    end;
end;
end;

但是,在登录对话框中点击取消后应用程序不会终止但显示我的主表单。我该怎么做才能纠正这个问题?

此外,在这种情况下,如果密码错误,如何刷新消息?

Firedac正在连接到SQL Server。

PS

即使这样也行不通:

.....
except
  on E: EFDDBEngineException do
  if E.Kind = ekUserPwdInvalid then
      begin
        ShowMessage('A user name or a password are invalid');
        Abort;
      end;

0 个答案:

没有答案