query1.sql.add('select * from dwdm where '''+edit1.text+'''='''+getPYStr(dw)+''')
 

解决方案 »

  1.   

    不拼接SQL语句,用参数。
    var
      strSQL:='SELECT * FROM dwdm where getPYStr(dw)=:AValue';
      with Query1 do
      begin
        Close;
        SQL.Text:=strSQL;
        Parameters.ParamByName('AValue').AsString=Edit1.Text;
        Prepared;
        Open;
      end;
      

  2.   

    adailee(不谈恋爱的铅笔)你好!运行的你语句出现错误如下:
    [Error] Unit3.pas(169): Undeclared identifier: 'Parameters'
    [Error] Unit3.pas(169): Missing operator or semicolon
    [Error] Unit3.pas(170): Statement expected, but expression of type 'Boolean' found
    不知道应该处理,请指教!!!
      

  3.   

    有什么问题??
    var
      strSQL:='SELECT * FROM dwdm where getPYStr(dw) like :AValue';
    begin
      query1.Close;
      query1.SQL.Text:=strSQL;
      query1.ParamByName('AValue').AsString=Edit1.Text;
      query1.open;
    end;
      end; 
    可以吗??
      

  4.   

    getPYStr 是数据库支持的函数吗? 还是你自己写的 Delphi 函数!
    SQL 语句中不能使用 数据库不支持的 函数 如:getPYStr
      

  5.   

    getpystr是自定义函数,如果SQL语句中不能使用,那我应该怎样才能实现呢?
      

  6.   

    就是用delphi自行设计的数据库,扩展名为.db