我用ADOQuery控件,查询问题,出现这样的错误。
我的程序;数据库用的是accessADOQuery1.Active:=false;
ADOQuery1.Sql.add('select * from test');
ADOQuery1.ExecuteSql;
ADOQuery1.Active:=true;......
ADOQuery1.Active:=false;
ADOQuery1.Sql.add('update test set id=1 name=2');
ADOQuery1.ExecuteSql;
ADOQuery1.Active:=true;//在第二次好像这句话会出错,错误如下:current provider does not support returning multiple recordset from a single execution;
然后,有弹出异常:
commandtext does not return a result set!这是什么原因,应该怎样改。
谢谢

解决方案 »

  1.   

    第二个
    ADOQuery1.ExecuteSql;
    改为
    ADOQuery1.open
      

  2.   

    上面说反了.
    ADOQuery1.open 返回记录集
    ADOQuery1.execsql 不返回记录集.所以 ::
    select 时用open.
    update 时用execsql改第一个..
      

  3.   

    可是我单用ExecSql查询select没有出错呀(第一段代码)!另:
    用ADOQuery1.open好像也不行难道不能两个都用ExecSQL吗?为什么?
      

  4.   

    ADOQuery1.Sql.add('select * from test');
    前要加
    adoquery1.sql.clear;
      

  5.   

    Call ExecSQL to execute the SQL statement currently assigned to the SQL property. Use ExecSQL to execute queries that do not return a cursor to data (such as INSERT, UPDATE, DELETE, and CREATE TABLE).ExecSQL returns an integer value reflecting the number of rows affected by the executed SQL statement.Note: For SELECT statements, call Open instead of ExecSQL or set the Active property to true.这样写试一下;
    ADOQuery1.Close;
    AdoQeruy1.Sql.clear;
    ADOQuery1.Sql.add('select * from test');
    ADOQuery1.Open;......
    ADOQuery1.Close;
    AdoQuery1.sql.clear;
    ADOQuery1.Sql.add('update test set id=1 name=2');
    ADOQuery1.ExecuteSql;
    .....
    呵呵,应该这样就没有问题了
      

  6.   

    update 语句'update test set id=1, name=2'  加逗号
      

  7.   

    ADOQuery1.close;
    adoquery1.sql.clear;
    ADOQuery1.Sql.add('update test set id='+#13+inttostr(1)+#13+' name='+#13+inttostr(2)+#13+'');
    ADOQuery1.ExecuteSql;