程序为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;
'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;
如:(中间件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;
试一下吧,肯定没有总题!
设了吗