dm.tp2.SQL.clear;
dm.tp2.SQL.text := ' select top 1 * from pjinfom where pjid= '+buildnew.Edit3.Text ;
dm.tp2.open;

解决方案 »

  1.   

    'select top 1 * from pjinfom where pjid= '+''''+buildnew.Edit3.Text+'''' ;''''代表一个'号
      

  2.   

    select top 1 * from pjinfom where pjid='+#39+trim(buildnew.edit3.text)+#39;
      

  3.   

    以上的方法都是错的
    如果buildnew.edit3.text中包含'呢?
    正确的方法是
    使用QuotedStr
      

  4.   

    dm.tp2.SQL.text := ' select top 1 * from pjinfom where pjid= '+buildnew.Edit3.Text ;
    改为
    dm.tp2.SQL.text := (format('select top 1 * from pjinfom where pjid=''%s''',[buildnew.Edit3.Text]));