Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Tengmin123
Frequent Visitor

Cannot display image in report builder from byte array or hex string

Hi, all,

 

I have a byte array (image) in json format in sql db. I extract the image out and also in json format. my query is:

SELECT thumbNail FROM Table
cross apply openjson(CMD_LIST,'$.queueMessagePages')
with
(pageNo Int '$.pageNo',
[thumbNail] nvarchar(max) as JSON
) as jsonsvalues where ...

 Then I get the thumbnail in nvarchar(max). 

In the report builder, I customize a function to convert the byte array into hex string. the function is like:


Function ToHexString(ByVal bytes() As Integer) As String
Dim strB As New System.Text.StringBuilder
Dim ints(bytes.Length) As Integer
Dim N as long
For N = 0 To bytes.Length - 1
If bytes(N) < 0 Then
ints(N) = bytes(N) + 256
Else
ints(N) = bytes(N)
End If
Next

For N = 0 To ints.Length - 1
If ints(N) < 16 Then
strB.Append("0" & Hex$(ints(N)))
Else
strB.Append(Hex$(ints(N)))
End If
Next

ToHexString ="0x" & Replace(strB.ToString().ToUpper(), " ", "")
Return ToHexString
End

 

I tried to run this function in vb,net can get the hex string correctly. but cannot get the image in report builder.

Please help to visualize the image in report builder if you have any experience. Thank you!

@v-janeyg-msft 

6 REPLIES 6
AbhiSSRS
Solution Sage
Solution Sage

The rdl supports Byte Array so you do not need to convert to hex! We have been converting the hex to bytearray if at all! Try to put this on a Dataset field and bind that to the image control. Also just to make sure the image mime is as of the original one.

 

AbhiSSRS_0-1625047561863.png

 

 

Thank you for your reply.  but my byte array is saved as varchar(max) in database, it is a string with byte array value. is it still ok for report builder to visualize it?

Yeah it should work! try adding this convert 

Convert.FromBase64String

I tried add the convert and not add, but both not work for me. 

Tengmin123_0-1625104647292.png

 

v-janeyg-msft
Community Support
Community Support

Hi, @Tengmin123 

 

After my search, I'm afraid that vb language is not supported .

Sorry, I have no experience in this area. I only used the following method to add images to the desktop. You can reference:

How to upload multiple images to SQL Server (sqlshack.com)

 

Best Regards

Janey Guo

Thank you for your reply.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.