Home > Back-end >  ClientDataSet1 and ClientDataSet2 OPEN at the same time not updated
ClientDataSet1 and ClientDataSet2 OPEN at the same time not updated

Time:11-03

Strange questions, ClientDataSet1 and ClientDataSet2 OPEN at the same time, but when I press BitBtn_SAVE preservation, display is to save the data, but after the search or the original data, there is something wrong with?
Procedure TForm1. BitBtn_CXClick (Sender: TObject);
The begin
//query
ClientDataSet1. RemoteServer:=DSProviderConnection1;
ClientDataSet2. RemoteServer:=DSProviderConnection1;
Try
ClientDataSet1. Close;
ClientDataSet1.Com mandText:='SELECT U_id, U_name FROM T_USER';
ClientDataSet1. Open;
DBGridEh1. The DataSource:=DataSource1;
DataSource1. The DataSet:=ClientDataSet1;


ClientDataSet2. Close;
ClientDataSet2.Com mandText:='SELECT U_XH, U_MC FROM T_BJ';
ClientDataSet2. Open;

With ClientDataSet2 do
The begin
Combobox1. Items. The Add (Trim (ClientDataSet2 FieldByname (' U_MC). AsString) are identical);
ClientDataSet2. Next;
end;

Except,
On E: the Exception do
The begin
Application. MessageBox (' failure ', 'prompt', mb_iconinformation + mb_ok);
end;
end;

end;


Procedure TForm1. BitBtn_SAVEClick (Sender: TObject);
The begin
//save
ClientDataSet1. Edit;
ClientDataSet1. FieldByName (' U_name '). AsString:=Edit1. Text;
ClientDataSet1. ApplyUpdates (1);
Application. MessageBox (PChar (' successfully saved '+ CHAR (13) + CHAR (13)),' tip 'mb_iconinformation + mb_ok);
end;

CodePudding user response:

If you comment out the following this paragraph can be saved, what the hell is this?
ClientDataSet2. Close;
ClientDataSet2.Com mandText:='SELECT U_XH, U_MC FROM T_BJ';
ClientDataSet2. Open;

With ClientDataSet2 do
The begin
Combobox1. Items. The Add (Trim (ClientDataSet2 FieldByname (' U_MC). AsString) are identical);
ClientDataSet2. Next;
end;

CodePudding user response:

1, in principle you ClientDataSet2 just give combobox1 data, after use should be shut down;
2, at the same time open two ClientDataSet is ok, don't know what you are here, there are other reasons, on the ClientDataSet actually data locally, and with the server has been disconnected,

CodePudding user response:

ClientDataSet1. FieldByName (' U_name '). AsString:=Edit1. Text;
Need to POST to use applyupdate, here?

ClientDataSet1. ApplyUpdates (1);
  • Related