Results 1 to 6 of 6

Thread: cDbImageContainer won't display Image from DB

  1. #1
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    11,085

    Default cDbImageContainer won't display Image from DB

    Hi -

    Latest Version (3.2) with DF 20.1 (also latest) & MS SQL Server 2019.

    I have BMPs stored in a VarBinary(Max) column that are large (1024 x 768 - but I've also tried 1/2 that: 512 x 384). I can view the DB image in an external image viewer (product named "SQL Image Viewer"), but no matter what I've tried, I cannot get them to display in a cDbImageContainer. The object is basically copied from the demo (which displays its own images just fine - Amy Aller has a mischevious smile, BTW):

    Code:
                Object oHLDExternalLeakChart is a cDbImageContainer
                    Entry_Item HLDImageData.vData
    
                    Set Server to oHLDImageData_DD
                    Set Location to 5 485
                    Set Size to 222 273
                    Set psToolTip to "Graph"
                    Set peImageStyle to ifOriginal
                    Set pcBackColor to (GetSysColor (clBtnFace iand $FFFFFF))
    
                    Procedure DrawHistogram
                        Handle hoImage
    
                        Get phoImage to hoImage
                        If (hoImage <> 0) Begin
                            Send DrawHistogram of oHistogramDialog hoImage
                        End
                    End_Procedure
                End_Object
    The image is created on disk from the CJ Chart Control & is then saved to the DB & the disk file is then deleted. The initial BMP can be viewed NP as well as once it's in the DB (as I mentioned above). I'd prefer to save as a JPG, but the Chart Control seems to want to only save BMPs.

    The record in HLDImageData is definitely being found. Any ideas as to what I might try?

    Also - I copied the VarBinary column to a record in the Graphics Demo table (PersonPhoto) & the demo will not display it either.

    ETA: DR 8.1 RDS will not show the images either. The attached image shows an image in the SQL Image Viewer tool (last record, ID # 35 is what's displayed).

    Click image for larger version. 

Name:	HLDImage.JPG 
Views:	66 
Size:	112.8 KB 
ID:	15574
    Last edited by Garret Mott; 3-Aug-2022 at 09:27 AM.
    Garret

    Time for an oldie but goodie:

    "If it ain't broke, you're not trying." - Red Green

  2. #2
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    11,085

    Default Re: cDbImageContainer won't display Image from DB

    False Alarm. I was using some old DF code to load the image from disk to the DB. Seems it wasn't fully correct. Switching to embedded SQL solved the problem:

    Code:
    (SELECT * FROM OPENROWSET(BULK N'C:\img\1.png', SINGLE_BLOB)
    Works perfectly. In fact, it works so much better, it's able to upload a jpg created from the chart control - which the old code would not do. Since the jpg is about 10% of the size of the bmp, it's much more better.
    Garret

    Time for an oldie but goodie:

    "If it ain't broke, you're not trying." - Red Green

  3. #3
    Join Date
    Feb 2009
    Location
    Brazil
    Posts
    5,446

    Default Re: cDbImageContainer won't display Image from DB

    but.. if your code was saving the bmp data wrongly in the database table.column, how the hell you could see the bmp image when looking at SQL directly ? Magic ???
    Samuel Pizarro

  4. #4
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    11,085

    Default Re: cDbImageContainer won't display Image from DB

    Very good question! All I can say is that it did show in that tool, but not in the DF tool.

    Now I have to figure out how to display a DB image in DR - it hates me so far.

    I've never been a fan of storing images in the DB, but I guess it's a requirement for this company.
    Garret

    Time for an oldie but goodie:

    "If it ain't broke, you're not trying." - Red Green

  5. #5
    Join Date
    Feb 2009
    Location
    Queens, NY, NY
    Posts
    7,429

    Default Re: cDbImageContainer won't display Image from DB

    If you store the images on disk, you can't use the database security to guarantee the integrity of the image data. You need to then add a whole other level of change control to the folder you're keeping the images in. It could be done that way, but then for every different install you do, you have to fight with the local IT team to get all the "special rules" past their "company policy" and that way lies madness.

    /MM
    Michael Mullan.
    Danes Bridge Enterprises.

    ++++++++++++++++++++++++++++
    There is just today. Tomorrow is a concept
    that is mostly theoretical. -- GM Wylie
    ++++++++++++++++++++++++++++

  6. #6
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    11,085

    Default Re: cDbImageContainer won't display Image from DB

    ...that way lies madness
    Already there... But you knew that.
    Garret

    Time for an oldie but goodie:

    "If it ain't broke, you're not trying." - Red Green

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •