mormot数据库连接+查询+序列为JSON

mormot数据库连接+查询+序列为JSON

uses SynDB,SynCommons, SynDBRemote, SynOleDB, SynDBMidasVCL, mORMotMidasVCL

procedure TForm1.FormCreate(Sender: TObject);
var
json: RawUTF8;
begin
DataBase := TOleDBMSSQLConnectionProperties.Create('127.0.0.1,8829', 'yndb', 'sa', 'sa');
// DBServer := TSQLDBServerHttpApi.Create(DataBase, 'jj', '6789', 'admin', 'admin', False, 8, nil, tmThreadPool);
qry:=TQuery.Create(DataBase.ThreadSafeConnection);
qry.Close;
qry.SQL.Clear;
qry.SQL.Add('select top 100 * from t2');
qry.Open;
json := qry.PreparedSQLDBStatement.FetchAllAsJSON(True);
qry.Free;
DataSource1.DataSet := JSONToClientDataSet(Self, json);
end;

posted @ 2017-12-16 16:54  delphi中间件  阅读(1726)  评论(0编辑  收藏  举报