高手 进来看看这个程序什么地主有错,

juckxu 2007-04-17 10:09:15
procedure TForm1.Button1Click(Sender: TObject);
var
mm,nn:string;
begin
if edit2.text = '' then
showmessage('请输入您的密码!')
else if edit1.Text = '' then
showmessage('请输入您的帐号!');
if (edit1.Text <> '') and (edit2.Text <> '') then
begin
ADOQuery1.Close;
ADOQuery1.SQL.Clear;
adoquery1.sql.add('select * from Admin where AdminID=:mm and Password=:nn');

adoquery1.parambyname('mm').asstring:=trim(edit1.text);
adoquery1.parambyname('nn').asstring:=trim(edit2.text);
showmessage('用户'+ edit1.text+'你好!系统检测中,请稍候!') ;
adoquery1.open;
if adoquery1.Fields[0].value = '' then
showmessage('帐号不存在!')
else if adoquery1.Fields[1].Value = edit2.Text then
begin
Form2.Show;
Form1.Close;
end
else
showmessage('登录失败,请检查用户名和密码!')
end;
end;

end.
...全文
226 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Hswinken 2007-04-30
  • 打赏
  • 举报
回复
showmessage('登录失败,请检查用户名和密码!')
单从语法看 这句要加分号

逻辑上 你查询后应该判断 返回的数据集 是不是为空. 比如
if adoquery1.RecordCount <1 then
//or
if adoquery1.IsEmpty then

//如果form1 是主窗体就不能用 close 用form1.hide

另外.open 前面用showmessage() 不是很合理,用label吧

说的不对的 大家指教


弘石 2007-04-28
  • 打赏
  • 举报
回复
应该是
form2.showmodal
并且去掉
f.close;
tony_102 2007-04-18
  • 打赏
  • 举报
回复

试试
adoquery1.sql.add('select * from Admin where AdminID=:'''mm''' and Password=:'''nn'''');
tony_102 2007-04-18
  • 打赏
  • 举报
回复
数据库内的用户名和密码都是字符串类型
你SQL传值就不是字符串了
tony_102 2007-04-18
  • 打赏
  • 举报
回复
明显SQL语句有问题
scvzhang 2007-04-18
  • 打赏
  • 举报
回复
'select count(*) from Admin where AdminID=:mm and Password=:nn'

if adoquery1.RecordCount >0 then
OK
else
ERROR
ls_d88 2007-04-18
  • 打赏
  • 举报
回复
不之所云,不过用参数查询的话好像要设置好几个的波。
chenzhuo 2007-04-18
  • 打赏
  • 举报
回复
报什么错?

adoquery1.parambyname('mm').asstring:=trim(edit1.text);
adoquery1.parambyname('nn').asstring:=trim(edit2.text);

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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