SetBlobData and GetData syntax

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 10
Joined: Mon 26 Jun 2006 19:23

SetBlobData and GetData syntax

Post by Zoran565 » Wed 03 Jan 2007 00:54


I have 16-byte field defined as 'MD5Digest: array [0..15] of byte' in Delphi and defined as 'Binary(16)' in the table.

This is how I set parameter in TMSQuery (when I do Insert):

qryMD5.ParamByName('MD5').SetBlobData(@MD5Digest, SizeOf(MD5Digest));

This is how I read that value later from the table (using another TMSQuery):


It seems that I am getting correct results.

Is this correct? If not, what is the proper syntax? In Insert statement can I use SetData(pointer) instead of SetBlobData(pointer, length)?

D2006, latest SDAC version, MSSQL 2005.


Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Fri 05 Jan 2007 13:19

The way you work with BLOB fields is correct, but we recommend you to use a TBlob object.
The TBlob object holds large object value for field and parameter.
You can use it like shown

Code: Select all

  MemData ...
procedure TForm1.FormCreate(Sender: TObject);
  Blob: TBlob;
  MD5Digest: array [0..15] of byte;
  Blob := MSQuery.GetBlob('BlobField');
  Blob.Read(0, Length(MD5Digest), @MD5Digest[0]);
  Blob.Write(0, Length(MD5Digest), @MD5Digest[0]);

For more information about TBlob class please see SDAC help.

Post Reply