Page 1 of 1

Can not save JPEG Image to Image Field

Posted: Tue 07 Feb 2006 08:24
by ekarasu
I can not save a jpeg image to a image field. I use the following code:

TJPEGImage *jp;
....
TStream *Stream1=NULL;
Query->Edit();
Stream1 = Query->CreateBlobStream(Query->FieldByName("Logo"), bmWrite);
jp->SaveToStream(Stream1);
Query->Post();

I don't get an error message but there is nothing written to the database either. I am sure that jp holds the related image.

Posted: Tue 07 Feb 2006 08:36
by Ikar
You can find similar Delphi example in Sdac\Demos\Win32\Pictures\ folder. We don't have samples other than included in the installation package.

Posted: Tue 07 Feb 2006 12:00
by tinof
I had a similar problem, the following sequence solved it :

query.fieldbyname('MyBlobField').Clear; // i think THIS is it !
stream:=TBlobStream(q.CreateBlobStream(q.fieldByName('myBlobField'),bmWrite));
stream.Seek(0,soFromBeginning);
stream.Write(data,len); // should work with savetostream too
query.post

Maybe it can help