[Lazarus] Adding blob data to MSSQL database

Reinier Olislagers reinierolislagers at gmail.com
Fri Oct 4 10:19:59 CEST 2013


On 04/10/2013 08:24, Richard Mace wrote:
> I am using the native components that come with Lazarus and can
> successfully connect and retrieve data from a MSSQL database.
> However, I am now needing to add data to the database, and have read
> many examples of adding strings or integer's to the database, but I
> can't find any with an example of adding blob data.
> Would somebody mind showing me an example of code that would do this?


For BLOBs stored in files
TBlobField(FData.Fields[1]).LoadFromFile('blobfield.bin');
should work. There's also LoadFromStream and in FPC trunk, you can use
e.g. .AsBytes to assign a byte array.

BTW, for mssqlconn, as documented in the readme and the FPC
documentation, it's useful to set this parameter:
<yourconnection>.Params.Add('TEXTSIZE=2147483647'); //Large (>16 MB)
blob support




More information about the Lazarus mailing list