• 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.
  • Posts

    • Streaming was exciting and new in the beginning, nowadays all these services just s#ck big time. Sh#tty shows, cancellations even before a first season has aired, ads, more ads and ever increasing prices. Like I said in a previous post, invest some time setting up a local media server and be way happier. 😉
    • First thing that popped into my head reading this as well.....
    • Windows 11/10 package manager UniGetUI gets massive update with bulk download options by Usama Jawad UniGetUI (formerly WinGetUI) is a considerably popular Windows package manager. It basically combines command-line interfaces from package managers like Chocolatey, pip, npm, and more, in a single intuitive GUI. The project is available on GitHub under the MIT license, sporting almost 17,000 stars and 547 forks, and a decent amount of watchers. Today, UniGetUI has received version 3.3.0. It is interesting to note that this release was actually meant to be version 3.2.1, following on from a respectable 3.2.0 release back in May. But since it features a massive change log with more changes than originally planned, the developer decided to bump it up to version 3.3.0 directly. The highlights from the latest release include an option to bulk-download installers, select a package manager executable, default install options for each package manager, and cloud backup and restore functionalities. In addition, more commands are now supported, and users have the ability to kill processes before installing, uninstalling, or updating a package. There are lots of other capabilities in tow, too. PowerShell7 now clears older versions when updating, the Searchbox has been moved to improve space utilization, the toolbar has been enhanced, internal error detection mechanisms have been upgraded, and some dialog boxes have netted updates. There are tons of other backend changes too, including a note that XAML and YAML files cannot be created anymore due to low usage - the developer says that these formats are only used by 0.7-1.3% of all bundles, so it's difficult to maintain the development overhead required to manage them. As expected, there are lots of fixes contributed by the very active UniGetUI community, too. You can find out the full details in the massive change log here. You can download UniGetUI version 3.3.0 stable from the Neowin software stories page or from its official GitHub repo linked above.
    • Sounds useful. It isn't reading your messages and sending them to Google ffs.
  • Popular Contributors

    1. 1
      +primortal
      504
    2. 2
      ATLien_0
      207
    3. 3
      Michael Scrip
      205
    4. 4
      Xenon
      141
    5. 5
      +FloatingFatMan
      116
  • Tell a friend

    Love Neowin? Tell a friend!