简体   繁体   中英

Convert TByteDynArray to TStream in Delphi

如何在Delphi中将TByteDynArray转换为TStream并将其保存在数据库中

To save it on a Stream, create a MemoryStream and write your ByteDynArray on it :

  ResultStream := TMemoryStream.Create;
  ResultStream.Write(MyByteDynArray, Length(MyByteDynArray));
  ResultStream.Position := 0;

To save it on a database, create a query object (FDQuery, ADOQuery, ...) with a parametrized SQL statement :

update MyTable set MyColumn = :Data where Id = 1;

and load your Stream on that parameter :

MyQuery.ParamByName('Data').LoadFromStream(ResultStream);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM