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.
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!
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.
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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
5 | |
4 | |
3 | |
3 |
User | Count |
---|---|
13 | |
11 | |
7 | |
3 | |
3 |