Board index » delphi » blob field problem, pls help.

blob field problem, pls help.

I am using Delphi 6 enterprise, Oracle 8i.
Try to save some jpeg files to a blob field in Oracle.
I have the following code to save the jpeg file.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var fs : TJpegimage;
begin
       if OpenPictureDialog1.Execute then
       begin
         strFileName := OpenPictureDialog1.FileName;
         fs := tjpegimage.Create;
         fs.LoadFromFile(strFileName);
         try
           with DM_Product.qy_BlobByProduct do
           begin
             if (State = dsbrowse) then
               DM_Product.qy_BlobByProduct.Edit;
             dm_product.qy_BlobByProductBLOB_CTN.Assign(fs);
             //dm_product.qy_BlobByProductBLOB_CTN.LoadFromStream(fs);
             Post;
           end;
         finally
           fs.Free;
         end;
end;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When a jpeg file is pick, the code
"dm_product.qy_BlobByProductBLOB_CTN.Assign(fs);" (I tried loadfromstream as
well but same result) returns Error "EInvalidGraphic - Bitmap image is not
valid".  However, when a bitmap file is picked, the file is saved
successfully.

I have seen the PLSQL to save jpeg file into the field, so I suppose it is a
problem with Delphi.  Anyone can help me to make the code work please?

 

Re:blob field problem, pls help.


If the blob field is attached to a TdbImage, that is where the error
originates.  It doesn't automatically translate from JPG to bmp.  I
currently use an Oracle blob for jpg storage, and I use only the
TBlobField.LoadFromFile('myjpg.jpg') to get the original jpg file and
store it in the blob.  In my case, I am using TImage/TJPEGImage rather
than TdbImage, so off the top of my head, I don't know what you would
need to to to make TdbImage work if that is what you are using.

Quote
Tony wrote:
> I am using Delphi 6 enterprise, Oracle 8i.
> Try to save some jpeg files to a blob field in Oracle.
> I have the following code to save the jpeg file.
<snip>
> When a jpeg file is pick, the code
> "dm_product.qy_BlobByProductBLOB_CTN.Assign(fs);" (I tried loadfromstream as
> well but same result) returns Error "EInvalidGraphic - Bitmap image is not
> valid".  However, when a bitmap file is picked, the file is saved
> successfully.

Re:blob field problem, pls help.


Quote
> var fs : TJpegimage;
> begin
>        if OpenPictureDialog1.Execute then
>        begin
>          strFileName := OpenPictureDialog1.FileName;
>          fs := tjpegimage.Create;
>          fs.LoadFromFile(strFileName);

LoadFromFile will not convert a Bitmap to a Jpeg, you need to load into a
bitmap then:

  fs.Assign(myBitmap);

That works with MSSQL, I assume it's the same with Oracle, but I haven't
tried it, and I don't know how you're going to deal with the situation if
you don't know what image type is being selected.

Regards
Dean Bisseker
Leeds, England

Other Threads