多层的问题:如何解决这个错误--Cannot perform this operation on an open dataset

nwp006 2003-03-09 06:27:23
我做了个多层的数据库应用软件,服务器端放了TADOConnection、TADOQuery、TDataSetProvider;客户端放了TSocketConnection、TClientDataSet1、TDataSource;现在访问和修改数据都很正常,但在添加记录时会提示服务器端的数据集出现错误:Cannot perform this operation on an open dataset。如果说要关闭该数据集则如何关闭?但如果是多用户则又如何解决(关闭该数据集后可能会影响他人使用)?高分求解(分不够再加)。代码如下:
sql:='Insert into Personinfo (TypeMark,Name,EName) value(';
sql:=sql+Edit1.Text+',';
sql:=sql+Edit2.Text+',';
sql:=sql+Edit3.Text+')';
DataModule1.ClientDataSet1.Close;
DataModule1.ClientDataSet1.CommandText:=sql;
DataModule1.ClientDataSet1.Execute;

...全文
1361 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
黄海之滨渔夫 2003-07-02
  • 打赏
  • 举报
回复
DataSetProvider--Options--poAllowCommandText

这个时必须的,但还有关键技术,remotedatamodule中的query的active必须为false
而且其sql属性不能为空,该填的还得填,
TOMWLD 2003-03-09
  • 打赏
  • 举报
回复
你试试在DataSetProvider的BeforeExcute事件里关闭数据集看看

Occurs before the provider passes an execute command to its dataset.

Delphi syntax:

property BeforeExecute: TRemoteEvent;

C++ syntax:

__property TRemoteEvent BeforeExecute = {read=FBeforeExecute, write=FBeforeExecute};

Description

Write a BeforeExecute event handler to respond to custom information from a client dataset before executing a query or stored procedure. Any parameter values supplied by the client dataset with the Execute command are applied before this event.

BeforeExecute is part of the mechanism by which a provider and a client dataset communicate information when executing queries or stored procedures that do not return cursors. When the provider is part of a stateless application server, this mechanism allows the provider and the client dataset to communicate persistent state information.

When the client dataset抯 Execute method is called, the following events occur:

1. The client dataset receives a BeforeExecute event, where it can encode custom information into an OleVariant.
2. The provider receives a BeforeExecute event, where the OleVariant from the client dataset appears as the OwnerData parameter. The provider can respond to or change that information before passing the execute command on to its dataset.
3. The provider dispatches its Execute method to execute a query or stored procedure.
4. The provider receives an AfterExecute event, where it can encode custom information into its OwnerData parameter or respond to information from the BeforeExecute event handler.

5. The client dataset receives an AfterExecute event, where it can respond to the custom information returned by the provider in its AfterExecute event handler.
nwp006 2003-03-09
  • 打赏
  • 举报
回复
这个属性我已经打开了
TOMWLD 2003-03-09
  • 打赏
  • 举报
回复
DataSetProvider--Options--poAllowCommandText

2,507

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧