Board index » delphi » Storing jpeg to blob question

Storing jpeg to blob question

Hello,

I have a database with a blob field and want to store jpeg images on it.
My code is:

DataMast.IBTFamiliaPhoto.Assign(Image1.Picture.Graphic);

IBTFamiliaPhoto is of type ftGraphic

I get the jpeg with a Picture Dialog and transfers it to the Image1 control,
then I need to store it on the database.

I get the error
    "Cannot assign a TJPegImage to a TBlobField"

Can you help me, ?

Thanks in advance.

A. Fresno
Valencia - Spain

P.S. Anyone knows where to get sample files ? , I never find enough
information on the guides and helps.

 

Re:Storing jpeg to blob question


Quote
"A. Fresno" wrote:

> I get the jpeg with a Picture Dialog and transfers it to the Image1 control,
> then I need to store it on the database.

> I get the error
>     "Cannot assign a TJPegImage to a TBlobField"

        Save the image to a TMemoryStream and load the Blob field from the
stream using the LoadFromStream method.

        HTH,

        -Craig

--
Craig Stuntz               Vertex Systems Corporation
Senior Developer           http://www.vertexsoftware.com

Delphi/InterBase weblog:   http://delphi.weblogs.com

Re:Storing jpeg to blob question


Od: "A. Fresno" <Alejandro.fre...@wanadoo.es>
Temat: Storing jpeg to blob question

Quote
> I get the jpeg with a Picture Dialog and transfers it to the Image1
control,
> then I need to store it on the database.

> I get the error
>     "Cannot assign a TJPegImage to a TBlobField"

At the lowest available level you can try to use sterams to cpy from one tho
another (TFileStream to TBlobStream), but there's a easier way, just load it
from file (TBlobField.LoadFromFile method).

Cheers
Jarek Zgoda

Other Threads