我在做一个系统,其中登陆窗体有问题。运行后有错误提示,如下:project project_salary.exe raised exception class EDatabaseError with message'Q_login:field'COUNT'not found',process stopped.点ok后光标停在了if
Q_login['COUNT']=1 then 这一行。
Q_login的SQL属性是:select count(id)
                      from person
                       where id=:user
                       and passwd=:passwd
                       and authority='5'
登陆窗体的源程序如下:
unit u_login;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, jpeg, ExtCtrls, Buttons;type
  TF_login = class(TForm)
    Panel1: TPanel;
    Image1: TImage;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    i_user: TEdit;
    i_passwd: TEdit;
    B_login: TBitBtn;
    B_cancel: TBitBtn;
    procedure B_loginClick(Sender: TObject);
    procedure FormShow(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  F_login: TF_login;implementation
uses salary, u_datamodule, crypt;{$R *.dfm}procedure TF_login.B_loginClick(Sender: TObject);
var
  passwd:String;
begin
  With DM_main do
  begin
    Database.Connected:=True;
    passwd:=i_passwd.Text;
    passwd:=Copy(passwd+passwd,1,10);
    passwd:=Encrypt(passwd,123);
    Q_login.Params.ParamValues['USER']:=i_user.Text;
    Q_login.Params.ParamValues['PASSWD']:=passwd;
    Q_login.Open;
  if Q_login['COUNT']=1 then
   begin
     Q_login.Close;
      Close;
    end
    else
   begin  //认证失败
      Application.MessageBox('请确认用户名和密码,注意大小写!', '认证失败',MB_OK);
      Database.Connected:=False;
    end;
  end;
end;
procedure TF_login.FormShow(Sender: TObject);
begin
  DM_main.Database.Connected:=False;
  i_passwd.Text:='';
end;
end.

解决方案 »

  1.   

    Q_login的SQL属性是:select count(id) as [count]
                          from person
                           where id=:user
                           and passwd=:passwd
                           and authority='5'
      

  2.   

    select count(id) as recocount
                          from person
                           where id=:user
                           and passwd=:passwd
                           and authority='5'
    ....
    if Q_login['recoCOUNT']=1 then
       begin
         Q_login.Close;
          Close;
        end
      

  3.   

    让我回去看看
    还有一个问题,请高手看看这句SQL语句是否有问题,谢谢!
    .....
    where department like:depart
      

  4.   

    where department like :depart //注意空格