with query1 do
begin
  close;
  sql.Clear;
  str:='select count(*) from 授权视图 where 工号='''+'X005'+''''
                 +' and 对象序号 = ''CY01''';   //faxingkeglform.UserID
  sql.Add(str);
  ExecSQL;
  q1:=Fields[0].asinteger;
end;
调试到q1:=Fields[0].asinteger这句时有问题
select count(*) from 授权视图 where 工号= 'X005' and 对象序号 = 'CY01'
查询结果为无标题
1高手救我?

解决方案 »

  1.   

    select count(*)  AS C  from
    if not query1.Eof then i:= query1.FieldByName('C').AsInteger;
      

  2.   

    将ExecSQL改为Open;
    SQL不返回值时(update、delete)时用ExecSQL
    返回值时用open;
      

  3.   

    我的sql查询
    C
    1
    但是i的调试值为11471988???
    这是这么回事????
      

  4.   

    //这样试试
    with query1 do
    begin
      close;
      sql.Clear;
      str:='select count(*) from 授权视图 where 工号='''+'X005'+''''
                     +' and 对象序号 = ''CY01''';   //faxingkeglform.UserID
      sql.Add(str);
      Open;
      if RecordCount>0 then q1:=Fields[0].asinteger;
    end;
      

  5.   

    返回数据集的SQL应该OPEN,改成OPEN就可以了.
      

  6.   

    不行呀,我用的是TQuery控件,好象没有open的过程
      

  7.   

    你才玩笑??? 
    出错信息为
    capability not supported