var
str:string;
begin
str:='select * from pjinfom where max(pjid) and sfid ='''edit4.text'''';
  with dm.query6 do
    begin
       close;
       sql.clear;
       sql.add(str);
       Open;
    end;
  if DM.Query6.RecordCount = 0
  then  edit1.text := '',
        edit3.text := '',
        edit5.Text := '',
        edit6.Text := '',
  else
        edit1.Text := dm.Query6.FieldList (name);......
这个语句有什么问题呢
help!!!!!

解决方案 »

  1.   

    'select * from pjinfom where max(pjid) and sfid ='''edit4.text''''这一条sql语句有问题,可以这样写
    select * from pjinfom where pjid=(select max(pjid) from pjinfom)
      

  2.   

    我记得以前用max(pjid)这样的语句检索出来的RecordCount是不可能等于0的,也就是说它的RecordCount至少大于1,所以你有一段代码肯定执行不到。
      

  3.   

    str:='select * from pjinfom where max(pjid) and sfid ='''edit4.text'''';
    改为
    str:='select * from pjinfom where max(pjid) and sfid =+''''+edit4.text+'''';
      

  4.   

    agree with mmtang3str:='select * from pjinfom where max(pjid) and sfid =+''''+edit4.text+'''';
      

  5.   

    单引号高的人心烦,
    str:='select * from pjinfom where max(pjid) and sfid ='+QuotedStr(edit4.text);