• 0

SQL Server - Select a blank image if field is null.


Question

I'm working on a project that uses Infragistics NetAdvantage Reporting to generate a report. The fields on the report are populated from a database using a stored procedure.

 

My problem is that one of the fields on the report is an image, and not all records in the database have a picture and if the field is NULL or invalid Infragistics puts a red X on the report. I need it to just be blank.

 

I'm trying to use something like this:

CASE WHEN Signature IS NULL THEN CONVERT(VARBINARY(MAX), 0) ELSE Signature END AS Signature

However this still results in a Red X if the Signature field is NULL. Is there some way to alter the statement so it will select a valid-but-blank image from the table?

 

5 answers to this question

Recommended Posts

  • 0

Have you tried using the ISNULL function, to provide an alternative value when the primary is null?

 

I'm not familiar with NetAdvantage Reporting, I tend to use T-SQL mostly, but a simple ISNULL should work fine..

 

SELECT   ISNULL(Signature, CONVERT(VARBINARY(MAX), 0)) AS Signature
FROM table
  • 0

The problem with returning a single zero byte when the field is null is that is still not a valid image any more than no data and would still produce a red X I'd assume. You'd probably need to use ISNULL to return a valid 1x1 res image.

 

possibly like this.

 

ISNULL(ColumnName, CAST(0x424d42000000000000003e0000002800000001000000010000000100010000000000040000000000000000000000000000000000000000000000ffffff008000000000 as varbinary(max)))

 

that should be the hex for a monochrome white 1x1 res bmp.

  • 0

Update: I got this working using a "Visibility" property on the report field I hadn't noticed originally.

 

It allows you to define a boolean statement to determine whether the image field will be shown or not, standard stuff.

  • Like 1
This topic is now closed to further replies.
  • Popular Now

  • Posts

    • The New Outlook is horrible at best. The one thing they push so hard at is that stupid ad that has to stay on top to promote their stupid Office 365. They can go to hell with that BS.
    • Nvidia shares Windows hotfix driver 576.66 for FC 25 crashes, browser video bugs, and more by Sayan Sen Nvidia has been on a roll lately with its release of hotfix drivers, which are essentially emergency display driver updates meant to fix issues.. The company's GeForce RTX 5000 series graphics cards have been plagued with several issues, and these hotfixes as well as the regular GameReady driver updates, are being pushed out to clear up the software side problems. The first hotfix was released in early March with version 572.65 that resolved black screen bootups. This was followed by another, version 572.75, that addressed clocking issues. After that, version 576.15 helped fix Windows Sleep and Modern Standby-related temperature monitoring bugs. With the latest hotfix driver update, 576.66, Nvidia says that it has resolved a video playback bug in web browsers that can lead to red-green flashing and similar corruption of that nature. Aside from that, the driver also fixes multiple game crashes including EA Sports FC 25, and more. Nvidia notes that the new hotfix driver is based on its latest GameReady driver 576.52. As a refresher, that driver added support for Nvidia's new RTX 5060. The full changelog for the new hotfix driver 576.66 is given below: Dune: Awakening may crash during gameplay [5273568] EA Sports FC 25 may crash during gameplay [5251937] [RTX 50 series] Dragons Dogma 2 displays shadow flicker [5252205] [RTX 50 series] Video playback in a web browser may show brief red/green flash corruption [5241341] Clair Obscur: Expedition 33 may crash [5283401] If you are encountering problems like the ones described above on Windows 11 or 10, you should definitely try updating the driver to the hotfix version here. In order to download the update, head over to Nvidia's official website on this page where you can also view the driver's release notes.
  • Recent Achievements

    • Week One Done
      jrromero17 earned a badge
      Week One Done
    • One Month Later
      jrromero17 earned a badge
      One Month Later
    • Conversation Starter
      johnwin1 earned a badge
      Conversation Starter
    • One Month Later
      Marwin earned a badge
      One Month Later
    • One Year In
      fred8615 earned a badge
      One Year In
  • Popular Contributors

    1. 1
      +primortal
      242
    2. 2
      snowy owl
      156
    3. 3
      ATLien_0
      144
    4. 4
      +FloatingFatMan
      138
    5. 5
      Xenon
      131
  • Tell a friend

    Love Neowin? Tell a friend!