数据查询的一个问题

pgz_007 2008-05-17 12:18:32

程序的登录框, 点击登录按钮事件:(operator操作员表)

cmUserName:=mUserName.Text;
cmPassword:=mPassword.Text;
operator.Open;
operator.SetKey;
operator.FieldByName('username').AsString:=cmUserName;

if not operator.GotoKey then //奇怪,这里要加上not才能执行过去
begin
tmpPassword:=operator.FieldByName('Password').AsString;
tmpDept:=operator.FieldByName('Dept').AsString;
if (tmpPassword=cmPassword) and (length(tmpPassword)=length(cmPassWord)) then
begin
showmessage('登录成功');
operator.Close;
ModalResult:=mrAll;
Close;
end
else
begin
Application.MessageBox('密码不对!','系统登录',mb_OK+mb_ICONQUESTION);
digit:=digit+1;
if digit>3 then
begin
ModalResult:=mrAll;
operator.Close;
Close;
JXMainForm.Close;
end;
operator.Close;
end
-----------------------------------------------
为什么执行到if not operator.GotoKey then 这里一定要加上not才能登录的过去,否则就登录不过去呢?(现在操作员表里面只有一条记录,一个操作员)
...全文
43 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
blazingfire 2008-05-17
  • 打赏
  • 举报
回复
没有找到'username'=cmUserName的记录
试试
//// if not operator.GotoKey then //奇怪,这里要加上not才能执行过去
if operator.Locate('username', cmUserName, []) then
begin
tmpPassword:=operator.FieldByName('Password').AsString;
tmpDept:=operator.FieldByName('Dept').AsString;
if (tmpPassword=cmPassword) and (length(tmpPassword)=length(cmPassWord)) then
begin
showmessage('登录成功');
operator.Close;
ModalResult:=mrAll;
Close;
end
else
begin
Application.MessageBox('密码不对!','系统登录',mb_OK+mb_ICONQUESTION);
digit:=digit+1;
if digit>3 then
begin
ModalResult:=mrAll;
operator.Close;
Close;
JXMainForm.Close;
end;
operator.Close;
end
pgz_007 2008-05-17
  • 打赏
  • 举报
回复
up

2,495

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧