How to work with GUID field in Firebird database?

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for InterBase & Firebird in Delphi and C++Builder
Post Reply
VadimMescheryakov
Posts: 11
Joined: Tue 30 Nov 2010 04:17

How to work with GUID field in Firebird database?

Post by VadimMescheryakov » Wed 09 Dec 2015 10:33

Hello

How to work with GUID field in Firebird database?

I created next table:

create table test (id Integer, GUID char(16) octets);

How assign values to GUID fields from my applicaton?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: How to work with GUID field in Firebird database?

Post by ViktorV » Thu 10 Dec 2015 18:19

To set the GUID field value, you can use the following code:

Code: Select all

procedure TForm.Button1Click(Sender: TObject);
var
  GUID: TGUID;
  Arr: TBytes;
begin
  ClientDataSet.Edit;
  Arr := GUID.Create('{F0C5A5FC-8E64-48FB-80B0-A62FFED81E48}').ToByteArray;
  ClientDataSet.FieldByName('guid').AsBytes := Arr;
  ClientDataSet.Post;
  ClientDataSet.ApplyUpdates(0);
end;

Post Reply