Page 1 of 1
Store different files types in field blob type
Posted: Tue 30 Aug 2011 23:01
by erasmoga
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
Posted: Wed 31 Aug 2011 12:40
by AndreyZ
Hello,
We have already fixed this problem. This fix will be included in the next IBDAC build.
Dou you have any expected date for that next build
Posted: Wed 31 Aug 2011 18:20
by erasmoga
We're in a very important stage in our project... Do you have any idea of the date for that build to be released?
Posted: Thu 01 Sep 2011 11:26
by AndreyZ
We will release the new IBDAC version as soon as RAD Studio XE2 is released. Approximately it will happen in two or three weeks.
Store different files types in field blob type
Posted: Wed 21 Sep 2011 20:31
by erasmoga
I install the new version 4.0.1 ibdac, but continued with the same error.
I can guide or help with an example.
Thanks.
Posted: Thu 22 Sep 2011 08:05
by AndreyZ
Please send your sample to andreyz*devart*com, including a script to create a table.
Posted: Thu 22 Sep 2011 22:11
by erasmoga
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!
Posted: Fri 23 Sep 2011 09:03
by AndreyZ
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;
Posted: Fri 23 Sep 2011 17:56
by erasmoga
Thanks for the quick reply and Thanks for the examples are simple and functionaly.
Posted: Mon 26 Sep 2011 07:59
by AndreyZ
Feel free to contact us if you have any further questions about IBDAC.