请问我这段delphi程序错在什么地方?

来源:百度知道 编辑:UC知道 时间:2024/06/24 18:46:14
其中CanLogin和UserPower是定义在public的变量。
出现的错误是,不管怎么输入用户名和密码,都出现messagebox提示输入错误。

procedure TFormLogin.ButtonLoginOKClick(Sender: TObject);
begin
with ADOQueryUsers do
begin
Close;
SQL.Clear;
SQL.Add('select * from Users where 姓名=:姓名 and 密码=:密码 and 类型=:类型');
Parameters.ParamByName('姓名').Value:=EditUsername.Text;
Parameters.ParamByName('密码').Value:=EditPassword.Text;
Open;
if RecordCount=0 then
begin
Application.MessageBox('您的输入有误,请重新输入!','错误',MB_OK);
CanLogin:=false;
end
else
begin
UserPower:=Parameters.ParamValues['类型'];
CanLogin:=true;
FormLogin.Close;
end;
end;
end;

这个比较急用啊,请大家帮帮忙,谢谢!!

几个建议:
1、在你的数据库中用一个写死的sql 语句试试看能不能查到数据
2、数据库的字段最好不要用中文,有时候可能会出现一些想不到的错误
3、delphi中sql语句的参数名也最好不要用中文,原因同2

从程序本身来看没有什么逻辑上的错误