If you’re reading this, then like me you probably fiddled around for an hour or so, scratched a hole in your head and wondered how such an easy job can be so impossible.
We’re building a SQL Server Reporting Services report that displays an image retrieved from a database field. This is easy.. Assuming that you already know how to build a simple SSRS report, to add a database image, simply select the image field into your dataset, drop an image control onto your report and select its “value” to the value of the image field from your dataset.
If you try this using the SQL Server version of Northwind, you’re sure to have trouble. The image will not display and you’ll get a little red cross in the control.
After a quick google search I came across these sites:
Robert Porter speaks the fact that the images saved in the Northwind database are not standard GIF formats, but OEM. Basically caused by converting a MS Access database to SQL Server. There’s also some sample there, but that didn’t work for me. Eventually after a lot more research and help, we have this line of code that converts the OEM GIF image into one readable by SSRS:
System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!Photo.Value), 105))
If you must use Northwind’s original data to display an image on an SSRS report, then use the above line as the image value. Any other SQL Server image field would not need this and will work just fine by simply using the plain field value.
System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields!Photo.Value), 105))
If you must use Northwind’s original data to display an image on an SSRS report, then use the above line as the image value. Any other SQL Server image field would not need this and will work just fine by simply using the plain field value.
2 comments:
TNX
Thanks man... That did save a lot of time... Have a good day...
Post a Comment