with query2 do
    begin
      close;
      sql.clear;
      sql.Add('select ywqdm,ywqmc from xxsjk.custom.JT_XT_YWQDMB');
      open;
      if recordcount<>0 then
      begin
      while not eof do
      begin
      ywqdm_ComboBox.Items.Add(fields[0].asstring);
      ywqmc_ComboBox.Items.Add(fields[1].asstring);
      next;
      end;
      end
      else
      begin
      application.MessageBox('数据库中暂无业务区记录,请找静态数据管理人员联系!','警告',0);
      exit;
      end;
    end;

解决方案 »

  1.   

    应该这样写:
    sql.add('and FieldName='+#39+S+#39);
      

  2.   

    s:Double;
    sql.add('and FieldName='+S+''); 
      

  3.   

    To  hj_cn(风影):你的编译也通不过.
    看来大家还是倾向于写参数的.
      

  4.   

    这样就可以了;
    sql.add(' and FieldName='+floattostr(s)'); 
      

  5.   

    这样就可以了;
    sql.add(' and FieldName='+floattostr(s)); 
      

  6.   

    sql.add('select * from table where fieldname='''+xxxx+'''');
      

  7.   

    应该这样写:
    sql.add('and FieldName='''+S+'''');
    或者
    sql.add('and FieldName='#39+S+#39); 
      

  8.   

    应该这样写:
    sql.add('and FieldName='''+FloatToStr(s)+'''');
    或者
    sql.add('and FieldName='#39+FloatToStr(s)+#39);
      

  9.   

    FloatToStr是Delphi的函数,现在传递的是Double类型,可以转换.如果是DateTime或者其它类型,我在Sql语句中转换成Sting类型了,但是比较时又转换,岂不是影响了速度?
      

  10.   

    sql.add('and FieldName='+FloatToStr(s)+'');
      

  11.   

    大家看这帖子
    http://www.csdn.net/expert/topic/597/597651.xml?temp=.2367365