Page 1 of 1
What is the best way of load and read BLOB field?
Posted: Wed 29 Sep 2010 16:15
by tanghz
As the title. I saw your picture demo. However, that one only demoed insert blob filed. The title field is still empty. How to insert a real record e.g insert ID, title, filesize, blobfile
all in one go?
I also read you have TBlob method, and AsBlob. How to use them?
Can I use it directly like
dataset.insert;
dataset.fieldbyname('title').asstring:=title;
dataset.fieldbyname('blobfile').asblob.loadfromfile('filename');
dataset.post;
or with the UniSQL, what is the best way to do it?
thanks,
Posted: Thu 30 Sep 2010 08:58
by AlexP
Hello,
The asBlob property is implemented only in TDAParam class, you can use this property
to set and read the value of the BLOB parameter as string, for example
blob:TBlobData;
blob:= 'data';
TUniQuery.ParamByName('BLOB_PARAM_NAME').asBlob:=blob;
To insert the blob data you can use type casts, for example
TBlobField(TUniQuery.FieldByName('BLOB_FIELD_NAME')).LoadFrom.....
or
(TUniQuery.FieldByName('BLOB_FIELD_NAME') as TBlobField).LoadFrom....
or
BlobField: TblobField;
BlobField:=TUniQuery.FieldByName('BLOB_FIELD_NAME') as TBlobField;
BlobField.LoadFrom;
You can use this code to insert all field values including the Blob fields
TUniQuery.Insert;
TUniQuery.FieldByName('FIELD_1').asInteger:= 1;
TUniQuery.FieldByName('FIELD_2').asString:= 'test';
.......
TBlobField(TUniQuery.FieldByName('BLOB_FIELD_NAME')).LoadFromFile('File');
TUniQuery.Post;
Posted: Thu 30 Sep 2010 12:27
by tanghz
Hi , thanks for your clear answer. It shines some advantages of the UniDAC features. If you can provide some updated demos in your future release to highlight the difference between your way and the triditional Delphi way, we will all be glad to read them thro. I belive some of them same a lot of coding time.
Posted: Mon 04 Oct 2010 07:02
by AlexP
Hello,
Our products have many different possibilities, but unfortunately we can't include all of them in the demo project, if you have any specific questions you can post them to our forum or send by e-mail, and we will help you to resolve the issue.