with GZ_DM.User_Q do begin close ; SQL.Clear ; SQL.Add('Select * from GZ_User'); SQL.Add('where 用户编号 =: UserName'); SQL.Add(' and 密码 =: Passwd'); Parameters.ParamByName('UserName').Value := UserName_CB.Text ; Parameters.ParamByName('Passwd').Value := Password_E.Text ; Prepared ; open; end; if GZ_DM.User_Q.RecordCount=0 then begin S_LoginNum := S_LoginNum + 1 ; if S_LoginNum <3 then begin ShowMessage('用户名或密码错误!请重新输入!!!'); end else ModalResult := MrCancel end else begin S_UserName := UserName_CB.Text ; S_UserPass := PassWord_E.Text ; ModalResult := MrOK ; end;
----------------------------------------------
-
with GZ_DM.User_Q do begin close SQL.Clear UNPREPARED; SQL.Add('Select * from GZ_User'); SQL.Add('where :N1=用户编号'); SQL.Add(' and :N2=密码'); Parameters.ParamS[0].Value := UserName_CB.Text; Parameters.ParamS[1].Value := Password_E.Text; Prepared; open; end; 你试一下,看一看好不好用!
Project GZ.exe raised Exception class EDatabaseError with message 'User_Q: Parameter 'UserName' not Foud'. Process stopped. Use Step or Run to continue.
procedure TF_login.b_loginClick(Sender: TObject); begin try Database1.Connected:=True; Table_user.Filter:='ID=''+i_user.Text+''; Table_user.Filtered:=True; Table_user.Open; except Application.MessageBox('请与系统管理员联系。', '数据库连接错误!', MB_OK); Application.Terminate; end; if Table_user.RecordCount=1 then begin if Table_user['PASSWD']=i_passwd.Text then begin F_login.close; .......
end else Application.MessageBox('请确认密码,注意大小写!', '密码不匹配', MB_OK); end else Application.MessageBox('请确认用户名是否正确!', '无此用户', MB_OK);
SQL.Clear i:='Select * from GZ_User where 用户编号 =''+username_cb.text+'' and 密码 =''+password_e.text+'' SQL.Add(i); open; end; if GZ_DM.User_Q.RecordCount=0 then begin S_LoginNum := S_LoginNum + 1 if S_LoginNum <3 then begin ShowMessage('用户名或密码错误!请重新输入!!!'); end else ModalResult := MrCancel end else begin S_UserName := UserName_CB.Text S_UserPass := PassWord_E.Text ModalResult := MrOK end; ----------------------------------------------