mormot2 clientdataset
mormot2 clientdataset
unit Unit1; interface uses mormot.db.rad.ui.cds, mormot.core.variants, mormot.db.rad.ui, mormot.core.text, mormot.core.base, Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Data.DB, DBAccess, Uni, MemDS, Datasnap.DBClient, Vcl.Grids, Vcl.DBGrids, Vcl.StdCtrls, UniProvider, SQLServerUniProvider; type TForm1 = class(TForm) UniConnection1: TUniConnection; UniQuery1: TUniQuery; DBGrid1: TDBGrid; DataSource1: TDataSource; Button1: TButton; SQLServerUniProvider1: TSQLServerUniProvider; Memo1: TMemo; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var r: variant; s: rawutf8; cds: TClientDataSet; begin TDocVariant.New(r); r.status := 200; r.message := 'success'; UniQuery1.Close; UniQuery1.SQL.Clear; UniQuery1.SQL.Text := 'select * from tunit'; UniQuery1.Open; r.tunits := _json(DataSetToJson(UniQuery1)); s := VariantSaveJSON(r); Memo1.Text := s; cds := JsonToClientDataSet(Self, s); DataSource1.DataSet := cds; end; end.
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/17138954.html