当前位置:编程学习 > Delphi >>

adotable实现登陆找不到下一条记录delphi

with adotable1 do
begin
if trim(fieldbyname('name').Value) = trim(edit1.Text) then
begin
next;
if trim(fieldbyname('password').Value) = trim(edit2.Text) then
begin
showmessage('哎哎哎');
end else showmessage('密码错误');
end else showmessage('账号错误');
end;

我这样子写只能找到第一条记录

为什么不能找到第二条记录呢

还有就是我的adoquery哪里错了啊

with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select * from users where name=:n and password=:p');
parameters.ParamByName('n').Value := trim(edit1.Text);
parameters.ParamByName('p').Value := trim(edit2.Text);
open;
if parameters.ParamByName('n').Value=edit1.Text then
begin
if parameters.ParamByName('p').Value=edit2.Text then
begin
showmessage('denglu成功!');
end else showmessage('mima cuowu')
end else showmessage('用户名不存在')
end;

随便输入都可以成功登陆。

追问:

你能在我的代码上改下吗?跟我说说我的错在哪里。

答案:

with qry_log do
begin
Close;
SQL.Text := 'select * from ULT where ULT_USER =:username and ULT_PAS =:password';
Parameters.ParamByName('username').Value := Trim(EDIT_USER.Text);
Parameters.ParamByName('password').Value := Trim(EDIT_PAS.Text);
Open;
if IsEmpty then
begin
ShowMessage('用户信息错误,请核对您的用户名与密码是否正确,如您确定无误,请与开发人员联系!');
sPAS := '';
Abort;
end
else
sName := Trim(qry_log.fieldByName('ULT_NAME').AsString);
F_MAIN.RS_USER.Caption :=' '+' '+sName;
F_LOGIN.Close;
end;

看下,懂么

上一个:delphi中如何把图片保存到特定的位置
下一个:delphi怎么判断数据库表的数据是否为空

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,