使用查询时,字符型变量可以这样引用:ss:stringwith query1 do
 begin 
  ....
  sql.add('select * from table1 where col ='''+ss+'''');//col 为字符型字段
  ....
 end;
我想问的是:如果是数值型的变量该怎样引用?即:ss:integer;with query1 do
   begin
      ...
      sql.add('select * from table1 where col ='???????????');//col 为数值型字段
      ...
   end;

解决方案 »

  1.   

    sql.add('select * from table1 where col =' + inttostr(ss));
      

  2.   

    sql.add('select * from table1 where col ='+inttostr(1234)+'"')
      

  3.   

    sql.add('select * from table1 where col ='+inttostr(1234));
      

  4.   

    日期型:
    sql.add('select * from table1 where col ='+''''+datetostr(date())+'''');
      

  5.   

    你为什么不用参数呢?
    with adoquery do
    begin
      close;
      sql.clear;
      sql.add('select * from table1 where col =:col' );
      Parameters.ParamByName('col').value :=ss;
     try 
      open;
    except
      showmessage('error');
    end;end;