select count(clientid) as aVariant from table1 where comdate='2003-05-16'
我用上面的查询语句时报错:
Type mismatch in expression.
高手指教后面的'2003-05-16'应该怎么写才对?

解决方案 »

  1.   

    用参数
    where comdate=:comdate
    然后
    ParamByName('comdate') := EncodeDate(2003,5,16);
    然后再返回数据集
      

  2.   

    我的具体代码如下:
    try
    query1.Close;
    strday:=formatdatetime('yyyy-mm-dd',now);
    strSql:='select count (clientid) as acount from clientreginfo where comdate='+quotedstr(strday);
    query1.SQL.text:=strSql;
    query1.Prepare;
    query1.Open;
    except
    ....
    end;
    其中comdate字段定义为date型,
    运行时报错如题,各位大侠给看看,应该怎么改?
      

  3.   

    用参数传不报错了,但返回值却总是0
    而且不能察看query1.sql.text的完整的值
    郁闷!