Store different files types in field blob type

Discussion of open issues, suggestions and bugs regarding IBDAC (InterBase Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
erasmoga
Posts: 10
Joined: Thu 31 Mar 2011 16:47

Store different files types in field blob type

Post by erasmoga » Tue 30 Aug 2011 23:01

Hello, I'm developing an delphi application to store different files types .doc, .pdf, .mp3, .jpg, etc.
I’m use method:

Code: Select all

myIBCQuery.Append;
BlobField(myIBCQuery.FieldByName('FILE')).LoadFromFile(fileIn.FileName); // FILE = Type Blob in Firebird DataBase
myIBCQuery .FieldByName('EXT_DOCTO').AsString := UpperCase(ExtractFileExt(fileIn.FileName); // Extension in my delphi app
myIBCQuery .Post;

The app store the file, but after reopening the IBCQuery generates error message: ‘EAccessViolation with message ‘ Acces Violation at address 004034FA in Module Proyect. Write of Address 0E0E0E0E’
Do not know if I'm using the best method with the correct properties of the query.

I can guide or help with an example.

Delphi XE, Firebird 2.5, IBDAC 3.60.0.23 pro, Windows 7

AndreyZ

Post by AndreyZ » Wed 31 Aug 2011 12:40

Hello,

We have already fixed this problem. This fix will be included in the next IBDAC build.

erasmoga
Posts: 10
Joined: Thu 31 Mar 2011 16:47

Dou you have any expected date for that next build

Post by erasmoga » Wed 31 Aug 2011 18:20

We're in a very important stage in our project... Do you have any idea of the date for that build to be released?

AndreyZ

Post by AndreyZ » Thu 01 Sep 2011 11:26

We will release the new IBDAC version as soon as RAD Studio XE2 is released. Approximately it will happen in two or three weeks.

erasmoga
Posts: 10
Joined: Thu 31 Mar 2011 16:47

Store different files types in field blob type

Post by erasmoga » Wed 21 Sep 2011 20:31

I install the new version 4.0.1 ibdac, but continued with the same error.
I can guide or help with an example.
Thanks.

AndreyZ

Post by AndreyZ » Thu 22 Sep 2011 08:05

Please send your sample to andreyz*devart*com, including a script to create a table.

erasmoga
Posts: 10
Joined: Thu 31 Mar 2011 16:47

Post by erasmoga » Thu 22 Sep 2011 22:11

Hi AndreyZ,

My apologies, the error was in a bad statement that has nothing to do with ibdac, the new version 4.0.1 works excellent, the technique I used was this:

Code: Select all

myIBCQuery.Append; 
StreamFile := TFileStream.Create(fileIn.FileName, fmOpenRead or fmShareDenyWrite);
try
   myIBCQuery.FieldByName('ID_DOC').AsInteger := id_document;
   StreamFile.Seek(0, soFromBeginning);
   TBlobField(myIBCQuery.FieldByName('DOCUMENT')).LoadFromStream(StreamFile);
   myIBCQuery.FieldByName('EXTENTION').AsString := UpperCase(ExtractFileExt(fileIn.FileName));
finally
   StreamFile.Free;
end;
Post;
This code works correctly, just tell me if this technique is correct.

Thanks!

AndreyZ

Post by AndreyZ » Fri 23 Sep 2011 09:03

You can use both approaches that you posted in this topic - both of them are correct. Here are examples:
1. using LoadFromFile:

Code: Select all

IBCQuery.Open;
IBCQuery.Edit;
TBlobField(IBCQuery.FieldByName('blobfieldname')).LoadFromFile('filename');
IBCQuery.Post;
2. usnig LoadFromStream:

Code: Select all

fs := TFileStream.Create('filename', fmOpenRead);
IBCQuery.Open;
IBCQuery.Edit;
TBlobField(IBCQuery.FieldByName('blobfieldname')).LoadFromStream(fs);
IBCQuery.Post;
fs.Free;

erasmoga
Posts: 10
Joined: Thu 31 Mar 2011 16:47

Post by erasmoga » Fri 23 Sep 2011 17:56

Thanks for the quick reply and Thanks for the examples are simple and functionaly.

AndreyZ

Post by AndreyZ » Mon 26 Sep 2011 07:59

Feel free to contact us if you have any further questions about IBDAC.

Post Reply