在我的Delphi程序中,我有一个登录表单,它在创建主表单之前显示,但我面临的问题是我想登录检查在主表单中处理,这意味着登录表单将使用要检查并继续的主要表格,
请阅读以下评论:
过程LogInButtonClick(Sender:TObject);
这是TLoginForm代码(来自delphi.about.com):
unit login;
interface
uses
Windows, Messages, SysUtils, Variants, Classes,
Graphics, Controls, Forms, Dialogs, StdCtrls;
type
TLoginForm = class(TForm)
LogInButton: TButton;
pwdLabel: TLabel;
passwordEdit: TEdit;
procedure LogInButtonClick(Sender: TObject) ;
public
class function Execute : boolean;
end;
implementation
{$R *.dfm}
class function TLoginForm.Execute: boolean;
begin
with TLoginForm.Create(nil) do
try
Result := ShowModal = mrOk;
finally
Free;
end;
end;
procedure TLoginForm.LogInButtonClick(Sender: TObject) ;
begin
if passwordEdit.Text = 'delphi' then
{
Here how it's possible to use : …Run Code Online (Sandbox Code Playgroud) 您好我有这个功能来使用TUniQuery更新我的Access数据库:
var
Res:Boolean;
begin
Res:=false;
try
with MyQuery do
begin
Active := false;
SQL.Clear;
SQL.Add('Update MYTABLE');
SQL.Add('set username='+QuotedStr(NewUserName));
SQL.Add(',password='+QuotedStr(NewPassword));
SQL.Add('where username='+QuotedStr(ACurrentUserName));
ExecSQL;
Res:=true;
end;
except
Res:=False;
end ;
Result:=Res;
end;
Run Code Online (Sandbox Code Playgroud)
使用Try ...除了足够知道"ExecSQL"成功或失败时?
或者还有其他更好的方法吗?
谢谢