首页 > 代码库 > 中间件datasnap用流传递数据
中间件datasnap用流传递数据
服务器端:
function TSvrMet.QuerySqlToStream(const cMess, sql: String; account: integer): TStream;
begin
d.fdQry.Close;
d.fdQry.sql.Text := sql;
d.fdQry.Open;
Result := TMemoryStream.Create;
d.fdQry.SaveToStream(Result, TFDStorageFormat.sfBinary);
Result.Position := 0;
end;
客户端:
var DataSnapClient: TSvrMetClient;
Stream: TStream;
begin
DataSnapClient := TSvrMetClient.Create(SQLConn.DBXConnection);
Stream := DataSnapClient.QuerySqlToStream(‘‘, ‘select * from GLFMKHJL‘, 1);
try
Stream.Position := 0;
FDMemTable1.Close;
FDMemTable1.LoadFromStream(Stream, TFDStorageFormat.sfBinary);
finally
//Stream.Free;//报错:invalid pointer operation,因为非此处创建则不必释放
DataSnapClient.Free;
end;
end;
中间件datasnap用流传递数据