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,
What is the best way of load and read BLOB field?
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;
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;
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.