删除时可以删除数据但是会出现异常
project project2.exe raised exception class EOleException with message'对象或提供者不能执行所需的操作 commandtext does not return a result set
主要代码
adoquery1.close;
adoquery1.SQL.Clear;
adoquery1.sql.add('delete from UserList where 用户名='''+u+'''');
adoquery1.ExecSQL;
adoquery1.open;
adoquery1.Close;
showmessage('已成功删除用户名为'+u+'的用户');

解决方案 »

  1.   

    1. adoquery1.close; 
    2. adoquery1.SQL.Clear; 
    3. adoquery1.sql.add('delete from UserList where 用户名='''+u+''''); 
    4. adoquery1.ExecSQL; 
    5. adoquery1.open;  //删掉,第2步已经Clear了,这里Open什么呢
    6. adoquery1.Close; //删掉
    7. showmessage('已成功删除用户名为'+u+'的用户');
      

  2.   

    open是打开数据集。你这里有数据集可以打开吗?没有吧?那就删掉吧。
      

  3.   

    adoquery1.open;
    adoquery1.Close;这两句没用
      

  4.   

    adoquery1.open;
                  --------------------删除这一句就行了!
      

  5.   

    adoquery1.close; 
    adoquery1.SQL.Clear; 
    adoquery1.sql.add('delete from UserList where 用户名='''+u+''''); 
    adoquery1.ExecSQL; 
    showmessage('已成功删除用户名为'+u+'的用户');
      

  6.   

    adoquery1.close; 
    adoquery1.SQL.Clear; 
    adoquery1.sql.add('delete from UserList where 用户名='''+u+''''); 
    adoquery1.ExecSQL; 
    adoquery1.open; ---你的数据集执行的不是查询,所以OPEN的时候无法返回数据而报错
    adoquery1.Close; 
    showmessage('已成功删除用户名为'+u+'的用户');
      

  7.   

    楼主的意思是删除后还想删除一下数据吧
    你可以在删除是换一个query来做,查询显示的是一个query
      

  8.   


    adoquery1.close; 
    adoquery1.SQL.Clear; 
    adoquery1.sql.add('delete from UserList where 用户名='''+u+''''); 
    adoquery1.ExecSQL;
    adoquery1.close;
    adoquery1.sql.text:='select * from UserList'; 
    adoquery1.open; 
    showmessage('已成功删除用户名为'+u+'的用户');//你原来的程序把SQL都已经替换了怎么可以Open