表a.
insert into a values("a","a")
select * from a
delete from a where name="a"
Update a set name="c" where name="a"在sql explorer执行正确,  sql:='insert into a values("a","a")';
  qry1.Close;
  qry1.SQL.Clear;
  qry1.SQL.Add(sql);
  qry1.ExecSQL ;怎么就错了呢?

解决方案 »

  1.   

    sql:='insert into a values('+QuotedStr('a')+','+QuotedStr(a)+')'; 
      

  2.   

      qry1.Close; 
      qry1.SQL.Clear; 
      qry1.SQL.Add('select * from a'); 
      qry1.open; 
      

  3.   


      sql:='insert into a values(''a'',''a'') ';   
      with qry1 do
      begin
        Close; 
        SQL.Clear; 
        SQL.Add(sql); 
        ExecSQL ;
      end;
      

  4.   

    lz 应该是你这里的写错了
    sql:='insert into a values("a","a")';
      

  5.   

      sql:='insert into a values(:a,:a)'; 参数前要加:
      

  6.   

    sql:='insert into a values(:a,:a)';==>sql:=format('insert into a values(%s,%s)',[a,a]);
      

  7.   

    //打开数据表函数
    procedure QueryOpen(Query:TADOQuery; SQLstr:string);
    begin
      Query.close;
      Query.sql.text:=SQLstr;
      try
        Query.Open;
      except
        showmessage('SQL语句有误!'+#13+SQLstr);
      end;
    end;//数据表执行语句函数
    procedure QueryEXEC(Query:TADOQuery; SQLstr:string);
    begin
      Query.close;
      Query.sql.text:=SQLstr;
      try
        Query.ExecSQL;
      except
        showmessage('SQL语句有误!'+#13+SQLstr);
      end;
    end;