当前位置:Gxlcms > 数据库问题 > mormot数据库连接+查询+序列为JSON

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

时间:2021-07-01 10:21:17 帮助过:24人阅读

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;

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

标签:var   class   state   roc   read   http   ida   api   .sql   

人气教程排行