程序为MIDAS,中间层使用Ado,客户端用SocketConnection连接.我在客户端想进行选取或更新操作,但是却都报告:
'qry_Oper:Cannot perform this operation on an open dataset'
(qry_Oper为我在中间层使用的AdoQuery控件名称。)已确认中间层的qry_Oper的SQL为空,Active为False,
DataSetProvider的poAllowCommandText为True。操作失败!不知是何原因?谢谢指教!
      with ClientDataSet do //选取
      begin
            Close;
            CommandText:='select * from User');
            Open;
        end;
OR
      with ClientDataSet do // 更新
      begin
            Close;
            CommandText:='Update User set Password='''+edt_Password.Text
                        +''', Ime='''+cb_Ime.Text+''' where AutoID='+IntToStr(gs_UserInfo.UserID);
            Execute;
       end;

解决方案 »

  1.   

    我猜想可能是你的客户端在第一次打开后,中间层的qry_Oper就一直处于打开状况
      

  2.   

    设定TDataSetProvider的Options属性的poAllowCommandText为True;
      

  3.   

    在前台这样操作恐怕不行,你可以写一个函数把SQL语句传给你的中间件,
    如:(中间件type library 增加一个函数 SetSQL 并增加一个参数strsql 类型BSTR)
    然后写代码(为什么不用ADODataSet呢,假设用ADODataSet1 取名为ds_Oper )
      ds_Oper.commandtext:=strsql;在前台调用时
          with ClientDataSet do //选取
          begin
            Close;
            SocketConnection.Appserver.SetSQL('select * from User');
            Open;
          end;
    试一下吧,肯定没有总题!
      

  4.   

    "设定TDataSetProvider的Options属性的poAllowCommandText为True"
    设了吗