Home > Back-end >  Delphi xe7 datasnap client update the data after read shows the number of lines is wrong again
Delphi xe7 datasnap client update the data after read shows the number of lines is wrong again

Time:11-02

Masters, consult the following problems
Delphi xe7 datasnap remote server is fdcquery, mysql,
Beginning of client with cliendataset joint query two tables (one is the orderlist, is a similar structure purchaselist form), display to the stringgrid,
Changes in stringgrid, use cdslist respectively, cdspurchase applyupdate to the database, after the update, you want to read the latest data displayed, but the problem lies in the joint to query the data rows is not correct, 4 rows of data, for example, after refresh sometimes 1 row, it is possible that line 6, 8,
Actually two tables in mysql data is right,
Please see what reason? Whether CDS just after applyupdate, haven't refresh datasetprovider?

 if (self. CdsHead. Active=false) or (self. CdsList. Active=false) then 
The begin
Showmessage (' data sets have open cannot submit update, ');
exit;
end;

Try
If self. CdsHead. ApplyUpdates (0)=0 then
If self. CdsList. ApplyUpdates (0)=0 then
If self. CdsPurchase. ApplyUpdates (0)=0 then
The begin
Application. MessageBox (' submit a server update is successful, ' 'tip');
end;
Except,
On E: the exception do
Showmessage (' submit server update error, '+ E.M essage);
end;
//update is finished to read data
Cdspurchase. Active:=false;
Cdspurchase.Com mandText:='UPDATE tbpurchaselist b, tborderlist a'
+ 'SET b. ` autoNumber `=a. ` autoNumber ` WHERE'
+ '(b. ` orderNo `=a.o rderno) AND (b. ` autono `=a. ` autono `)';
Cdspurchase. Execute;

Self. CdsList. Close;
Self.cdsList.Com mandText:=
'the SELECT a. ` AutoNumber `, a. ` AutoNo `, a. ` GroupMemo `, a. ` itemno `, a. ` a PartNumber `,'
+ 'a. ` CDes `, a. ` CQuantity `, a. ` CUnit `, a. ` Price `, a. ` Amount `, a. ` CRemark `,'
+ 'b. ` MyCode `, b. ` MyDesEN `, b. ` MyDesCHN `, b. ` MyUnit `, b. ` MyQty `,'
+ 'b. ` autoNumber `, b. ` supplycode `, b. ` supplyname `, b. ` costprice `,'
+ 'b. ` costCurrency `, b. ` discount `, b. ` costSum `, b. ` sremark `, b. ` orderno `,'
+ 'a. ` machinetype `, b. ` PONo `, b. ` transition `, b. ` Recieved `, b. ` itemno `'
'+' FROM tborderlist a LEFT JOIN tbpurchaselist b
+ 'ON a. ` AutoNumber `=b. ` AutoNumber `'
+ 'where a.O rderno="' + getOrderno + '" order by autono';
Self. CdsList. Active:=true;
//self. Cdslist. Indexfieldnames:='autono';
//showmessage (' to read the number of rows: + inttostr (self) cdslist) recordcount));
Clearrows (sgList);
ReadDataset (self. CdsList);//read the database records to the form of

CodePudding user response:

What I use is datasnap, code much less than you, is I use your FDMemTable memory table instead of CDS, have no code for you on the phone

CodePudding user response:

Now I use the CDS update submitted without error, is submitted, to read the record number, line number is wrong,

CodePudding user response:

It seems that no one know?

CodePudding user response:

Simply look at your code, logic should be correct, check the direction, after the update, check the database server has submitted properly, if submitted under normal circumstances, to check the correctness of the read data,

CodePudding user response:

Submitted after the database has the actual data,
In addition, if the above code execution after the window is shut, or through the form open tBUTTON re-open the read data, the reality is correct,
So strange,
  • Related