我在组合查询中,用以下语句可实现了对字符串的查询:
sql:= 'select * from where Sex='+ quotedstr(trim(EditEName.Text))
再用多个子sSQL:=sSQL+ 'EName = '+ quotedstr(trim(EditEName.Text))来实现组合现对字符串型数据通过,现请问对整型、实型和日期型该如何处理?
最好不要使用参数,能简单的用若干个SQL子串连成一个完整的SQL串

解决方案 »

  1.   

    字符型:
     SQLStr := SQLStr+' where Code_No='+''''+Edit1.Text+'''';
    整性:
     SQLStr := SQLStr+' where Item_Num='+Edit1.Text;
    或 SQLStr := SQLStr+' where Code_No='+IntToStr(Num);
    實型:
     SQLStr := SQLStr+' where Code_No='+''''+FloatToStr(Num)+'''';
    日期型:
     SQLStr := SQLStr+' where Code_No='+''''+DataTimeToStr(Date)+''''; //與字型串處理相同,隻不過函數為DateTimeToStr
      

  2.   

    上面一行寫錯了,應為:
    實型:
     SQLStr := SQLStr+' where Code_No='+FloatToStr(Num);
      

  3.   

    integer:
    var v_integer:integer;
    v_integer:=...;
    ...
    sql:='select * from table where integer_field='+inttostr(v_integer)+' and ...';
    其他的类似。
      

  4.   

    我同意 Bes96261(秋水孤鶩) 的写法