ClientDataSet and Provider??? (Change SQL) Help,help,help me. (25分)

  • 主题发起人 主题发起人 zyx1122
  • 开始时间 开始时间
Z

zyx1122

Unregistered / Unconfirmed
GUEST, unregistred user!
there are 2 form:Main and Sub
and a procdure named SetSQL in datamodule
////////////// Tdmclient::SetSQL ///////////////////////
Procdure TdmClient:SetSQL(strSQL : string)
begin
cdsMaster.close;
cdsMaster.CommandText := strSQL;
cdsMaster.open;
end;

///////////// TfrmMain::OnCreate //////////////////
Procdure TfrmMain::OnCreate(...)
var
strSQL : string;
begin
strSQL := 'select * from customer';
dmclient.SetSQL(strSQL);
end;

///////////// TfrmSub::OnCreate //////////////////
Procdure TfrmSub::OnCreate(...)
var
strSQL : string;
begin
strSQL := 'select * from orders';
dmclient.SetSQL(strSQL);
end;

And when I set the project's start form to frmMain
it can get customer's data.
When I set the project's start form to frmSub
it can get orders' data.
It's right.
// the problem is :
And now I set the project's start form to frmMain,
I add a command button named "OpenSubForm' in frmMain
and it's click event is
///////////// cmbOpenSubForm ////////////////////
Procdure TfrmMain:cmbOpenSubFormOnClick(...)
var
frmSub : TfrmSub;
begin
frmSub := TfrmSub.Create(self);
end
/////////////
When I click the command button,
the frmSub data is still customer,
not orders. Why?
I just have 25, It's a little pity.
 
建议不要在客户端直接给应用服务器发SQL命令,这样的话就体现不出三层的优势了,和C/S程序没有什么区别。
 
The same problem when I send SQL in server.
 
接受答案了.
 
要想更新应该在客户端执行完命令之后调用ClientDataset.Refresh,这样数据才会刷新到客户端,不过你必须保证客户端的所有更改已经提交,否则会触发异常。
 
后退
顶部