可以一次性序列(还原)多个TClientDataSet。
1)TClientDataSet查询数据
procedure TForm1.Qrys(accountno, sql, sql2: string; DataSet, DataSet2: TClientDataSet); // TClientDataSet主从表查询 var url: SockString; i: integer; serial: TynSerial; begin serial := TynSerial.Create; try url := ‘querys2‘; serial.WriteString(‘accountno‘, accountno); // 帐套号 serial.WriteString(‘sql‘, sql); // 查询SQL serial.WriteString(‘sql2‘, sql2); i := FHttp.Post(url, serial.Text, FDataType); // http post if i = 200 then begin serial.Text := FHttp.Content; serial.ReadClientDataSet(‘dataset‘, DataSet); // 还原一 serial.ReadClientDataSet(‘dataset2‘, DataSet2); // 还原二 end else ShowMessage(IntToStr(i) + ‘ error‘); finally serial.Free; end; end;
2)TClientDataSet提交数据
function TForm1.Save(accountno, tablename: string; dataset: TClientDataSet): string; // clientDataSet提交 var url: SockString; i: Integer; serial: TynSerial; begin serial := TynSerial.Create; try url := ‘save‘; serial.WriteString(‘accountno‘, accountno); serial.WriteString(‘tablename‘, tablename); serial.WriteDelta(‘delta‘, dataset); i := FHttp.Post(url, serial.Text, FDataType); if i = 200 then begin serial.Text := FHttp.Content; if serial.ReadBool(‘result‘) then dataset.MergeChangeLog; end else ShowMessage(i.ToString + ‘ error‘); finally serial.Free; end; end;
原文地址:https://www.cnblogs.com/hnxxcxg/p/10972275.html
时间: 2024-10-11 15:35:53