你试一下这样 if 用户名和密码匹配 then Succ:=true else Succ:=false; close;在窗口的onClose事件中 if not Succ then Application.terminate;
也许你可以改成这样: procedure TfrmUserLogin.BitBtn1Click(Sender: TObject); var strSqlString: String; begin strSqlString:= 'Select [User_Password] From [User_Information] Where [User_Name]='''+ edtUserName.Text+'''; DM.DoQuery(strSqlString, frmDM.adoquery); // if (frmDM.adoquery.bof And frmDM.adoquery.Eof) then if frmDM.adoquery.FieldByName('User_Password').asstring=edtPassword.Text then 显示主窗体 else begin showmessage('用户和密码不正确'); Application.Terminate; end end;
procedure TfrmUserLogin.BitBtn1Click(Sender: TObject); var strSqlString: String; begin strSqlString:= 'Select * From [User_Information] Where [User_Name]='''+ edtUserName.Text+''' And [User_Password]='''+ edtPassword.Text+''''; DM.DoQuery(strSqlString, frmDM.adoquery); if (frmDM.adoquery.bof And frmDM.adoquery.Eof) then begin showmessage('用户和密码不正确'); halt;//用这个不停也得停了 end end;
MainMenufrm.OnActivate :=nil;
Application.Terminate; //程序终止
Application.ProcessMessages;
if 用户名和密码匹配 then
Succ:=true
else
Succ:=false; close;在窗口的onClose事件中
if not Succ then
Application.terminate;
procedure TfrmUserLogin.BitBtn1Click(Sender: TObject);
var
strSqlString: String;
begin
strSqlString:= 'Select [User_Password] From [User_Information] Where [User_Name]='''+ edtUserName.Text+''';
DM.DoQuery(strSqlString, frmDM.adoquery);
// if (frmDM.adoquery.bof And frmDM.adoquery.Eof) then
if frmDM.adoquery.FieldByName('User_Password').asstring=edtPassword.Text then
显示主窗体
else begin
showmessage('用户和密码不正确');
Application.Terminate;
end
end;
var
strSqlString: String;
begin
strSqlString:= 'Select * From [User_Information] Where [User_Name]='''+
edtUserName.Text+''' And [User_Password]='''+
edtPassword.Text+'''';
DM.DoQuery(strSqlString, frmDM.adoquery);
if (frmDM.adoquery.bof And frmDM.adoquery.Eof) then
begin
showmessage('用户和密码不正确');
halt;//用这个不停也得停了
end
end;