TynSerial序列(還原)TClientDataSetsql
能夠一次性序列(還原)多個TClientDataSet。post
1)TClientDataSet查詢數據url
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提交數據orm
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;