Board index » cppbuilder » Saving Image to Access Database

Saving Image to Access Database


2006-10-10 11:05:52 PM
cppbuilder51
Hi
I am trying to save images to an OLE Object field in Microsoft Access
with the following code, but i am getting a couple of compile errors :-
Could not find match for BlobField
LoadFromStream is not a member etc - I think this is because of the first
message
Code as follows :-
String pictureName;
TMemoryStream *stream = new TMemoryStream;
TBlobField *field = new TBlobField;
pictureName = "C:\\MC\\Images\\Tulips.jpg";
stream->LoadFromFile(pictureName);
field = dynamic_cast<TBlobField *>
(wDataModule->tPlants->FieldByName("JPGImage")); // OLE Object
field in Database
wDataModule->tPlants->Edit();
// wDataModule->tPlants->FieldByName("JPGImage")->// commented out
// LoadFromStream(stream.get(), ftGraphic); //
commented out
field->LoadFromStream(stream.get(), ftGraphic);
wDataModule->tPlants->Post();
delete stream;
delete field;
Any help appreciated
Michael Corby
 
 

Re:Saving Image to Access Database

Have solved this problem with help from Thomas Maeder.
Thanks, Thomas.
Michael Corby
"Michael Corby" < XXXX@XXXXX.COM >wrote in message
Quote
Hi

I am trying to save images to an OLE Object field in Microsoft Access
with the following code, but i am getting a couple of compile errors :-

Could not find match for BlobField
LoadFromStream is not a member etc - I think this is because of the first
message

Code as follows :-

String pictureName;
TMemoryStream *stream = new TMemoryStream;
TBlobField *field = new TBlobField;

pictureName = "C:\\MC\\Images\\Tulips.jpg";

stream->LoadFromFile(pictureName);

field = dynamic_cast<TBlobField *>
(wDataModule->tPlants->FieldByName("JPGImage")); // OLE Object
field in Database

wDataModule->tPlants->Edit();

// wDataModule->tPlants->FieldByName("JPGImage")->// commented out
// LoadFromStream(stream.get(), ftGraphic); //
commented out

field->LoadFromStream(stream.get(), ftGraphic);

wDataModule->tPlants->Post();

delete stream;
delete field;



Any help appreciated

Michael Corby