当我运行时输入用户名和密码时总是出现密码不正确,各位高手帮我指出错误之处 不要帮我全都改掉 谢谢了procedure TForm1.Btn_loginClick(Sender: TObject);
begin
try
adoconnection1.open;
adoquery1.close;
adoquery1.Parameters.ParamByName('id').Value:=edit_user.Text;
adoquery1.Open;
Except
Application.MessageBox('请与系统管理员联系。','数据库连接错误!',mb_ok);
Application.Terminate;
end;
if adoquery1.Fields[0].value=null then
begin
Application.MessageBox('请确认用户名是否正确!','用户名错误!',mb_ok);
exit;
end;
if adoquery1.Fields[0].value=edit_passwd.Text then
begin
if adoquery1.Fields[1].value='2' then
begin
form_student.show;
end
else
Application.MessageBox('请选择合适的登录软件!','用户权限错误!',mb_ok);
end
else
Application.MessageBox('密码不正确,注意大小写!','密码错误!',mb_ok);
end ;procedure TForm1.btn_cancelClick(Sender: TObject);
begin
close;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
edit_user.Text:='';
edit_passwd.Text:='';
end;end.其中sql语句为:select passwd, authority from user where id=:id
数据库中的user表是
id char(6)
passwd char(15)
authority char(1)
begin
try
adoconnection1.open;
adoquery1.close;
adoquery1.Parameters.ParamByName('id').Value:=edit_user.Text;
adoquery1.Open;
Except
Application.MessageBox('请与系统管理员联系。','数据库连接错误!',mb_ok);
Application.Terminate;
end;
if adoquery1.Fields[0].value=null then
begin
Application.MessageBox('请确认用户名是否正确!','用户名错误!',mb_ok);
exit;
end;
if adoquery1.Fields[0].value=edit_passwd.Text then
begin
if adoquery1.Fields[1].value='2' then
begin
form_student.show;
end
else
Application.MessageBox('请选择合适的登录软件!','用户权限错误!',mb_ok);
end
else
Application.MessageBox('密码不正确,注意大小写!','密码错误!',mb_ok);
end ;procedure TForm1.btn_cancelClick(Sender: TObject);
begin
close;
end;procedure TForm1.FormCreate(Sender: TObject);
begin
edit_user.Text:='';
edit_passwd.Text:='';
end;end.其中sql语句为:select passwd, authority from user where id=:id
数据库中的user表是
id char(6)
passwd char(15)
authority char(1)
改为-->varchar(15)
或者
if adoquery1.Fields[0].value=edit_passwd.Text then
改为:if Trim(adoquery1.Fields[0].value)=Trim(edit_passwd.Text) then 惹要区别密码大小写,则改成:
if Comparestr(Trim(adoquery1.Fields[0].value),Trim(edit_passwd.Text)=0 then 试试...
第一种方法还是出现密码不正确;
第二种方法出现了list out of bound 的错误
三楼的设置断点跟踪怎么运用, 我不会啊 请各位高手再来帮帮忙吧! 我急用啊! 谢谢了
改成
select passwd, authority from user where rtrim(id) = rtrim(':id')
将select passwd, authority from user where id=:id
改为:select passwd, authority from user where id=:i_d另:
adoquery1.Parameters.ParamByName('id').Value:=edit_user.Text;
改为:
adoquery1.Parameters.ParamByName('i_d').Value:=edit_user.Text;
改成
select passwd, authority from user where rtrim(id) = rtrim(':id')
select passwd, authority from user where id
复到SQL查询分析器中就知道了