('select * form 数据库 where FIELD='''+CX_STRING+'''')

解决方案 »

  1.   

    1. Query.SQL.Add('Select * from TableName Where FieldName = ''' + cx_string + '''');
    2. memo.text  := cx_string;
      

  2.   

    cx_string := '1=1';
    query1.sql.clear;
    query1.sql.add( 'select * form 数据库 where '+ cx_string);
    query1.open
    memo1.lines.add(cx_string);
      

  3.   

    'select * from table where field= '''+cx_string+''''
    Memo1.Lines.add(cx_string)
      

  4.   

    With Query1 do begin
      sql.close;
      sql.clear;
      sql.add('Select * from tablename where field1 = :param1')
      sql.parambyname('param1') := cx_string;  
      sql.prepared;
      sql.open;
    end;
      

  5.   

    cx_string所形成的条件是多个字段的复合条件
    如cx_string:=z1>b1 and z2=b2 and z3<b3
    z1,z2,z3这字段名,b1,b2,b3为字符变量
    如何实现?
      

  6.   

    如cx_string:=z1>b1 and z2=b2 and z3<b3 中如果b1,b2,b3都是整形的话,你这么写是对的,但如果其中有字符串比较的话,就错了,假设z1是字符串
    类型的,应这样写cx_string:='z1>''b1'' and z2=b2 and z3<b3'
    不论什么情况,底下的语句都是对的 
    query1.sql.add( 'select * form 数据库 where '+ cx_string);