100分!!密码验证问题在线等待。。。。。。。。。。。。

wohoot 2002-11-29 07:32:37
原码如下:
(editpwd 密码输入,dbcombobox1 用户选择,mainform 主窗体)
procedure Tpdform.FormCreate(Sender: TObject);
begin
editpwd.Clear;
dbcombobox1.Items.Clear;
while not table1.Eof do
begin
dbcombobox1.Items.Add(table1.FieldByName('user').AsString);
table1.Next;
end;
end;


procedure Tpdform.okbtnClick(Sender: TObject);
begin
if editpwd.text='' then
showmessage('请输入密码!')
else
if trim(editpwd.text)<>Table1.fieldbyname('pd').asstring then
showmessage('密码错误!请重新输入密码!')
else
if (trim(dbcombobox1.text)=table1.FieldByName('user').asstring) and
(trim(editpwd.text)=Table1.fieldbyname('pd').asstring) then
mainform.Show;
end;

问题:不论选择哪个用户,密码以用户表中最后用户密码为准。请指教怎样解决?在线等待。100分。
...全文
34 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wohoot 2002-11-30
  • 打赏
  • 举报
回复
思路是这样:如是万能用户和密码就打开主窗口,关闭登陆窗口,如选择了用户,密码错显示重输,密码对就打开主窗口,关闭登陆窗口。
原码如下:
(editpwd 密码输入,dbcombobox1 用户选择,mainform 主窗体,wohoot 万能用户和密码)
procedure Tpdform.okbtnClick(Sender: TObject);
begin
if (dbcombobox1.text<>'wohoot') and (editpwd.text<>'wohoot') then
begin
table1.close;
table1.Open;
table1.First;
if (editpwd.text<>table1.Fieldbyname('pd').AsString) and not table1.Eof then
table1.Next;
if table1.Eof then
showmessage('密码错误,请重新输入!')
end
else
mainform.show;
end;

调试不能通过,请教到底出错在哪里?
wohoot 2002-11-30
  • 打赏
  • 举报
回复
按你的一改,密码都无效啦
radeonle 2002-11-29
  • 打赏
  • 举报
回复
先把table指到第一条记录,
然后 if 密码不对,并且 not table1.Eof 的时候 then
table1.next;
然后 if table1.eof then
showmessage('密码不对')
else
mainform.Show;
思路就是这样,其实用query比较好的。
radeonle 2002-11-29
  • 打赏
  • 举报
回复
因为你启动的时候table已经指到了最后一条记录了。
basai 2002-11-29
  • 打赏
  • 举报
回复
procedure Tpdform.okbtnClick(Sender: TObject);
begin
table1.close;
table1.open;

加这两句你试试

5,931

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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