in

Crystal Reports display Sql Image From Dataset

I am creating a dataset with an Image column from Sql 2005 in vb.net and binding it to a Crystal Report in the details section (different image per row).

I cannot get the Image to display, it comes into the dataset xml as xs:Base64.  

I am placing the field by dragging it from the field explorer onto the page, but suspect this is not the accurate way to do it.

I am using the bundled Crystal with Visual Studio, but do have Crystal XI full version available.

can someone explain how to display the Image from a dataset on the Crystal report?  I've googled myself into a frenzy without a clear explanation...





Solution: Crystal Reports display Sql Image From Dataset

okay, there were multiple problems. the thumbnail was in a compressed, propriatary format being used by an application called PrefGest.  

ultimately, I did the following for each row:
1. retrieved the xml data with the binary image rather than the thumbnail.
2. converted the xml into a Pref Image using Prefview.dll
3. streamed the PrefImage into a converted normal image
4. streamed the normal image back in a dataset.
5. attached Crystal to the dataset (written to disk)

code attached.  although it has a 3rd party component (PrefGest), it should give some clues if someone else runs into a similar problem.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
        Private Shared Function ConvertImages(ByVal ds As DataSet) As DataSet
            'ds.Tables("tDetail").Columns.Add("IMG", System.Type.GetType("System.Byte[]"))
            Dim convert As New bll.functions.PrefStreamConverter
            For Each row As DataRow In ds.Tables("tDetail").Rows
                row("IMG") = convert.GetBinaryStream(row("imgxml"), 200, 200) 'o.GetDecoded 'Convert.FromBase64String(Convert.ToBase64String(row("Thumbnail")))
            Next
            ds.AcceptChanges()
            Return ds
        End Function
 
Imports Interop.PrefView
Imports System.IO
Namespace bll.functions
    Public Class PrefStreamConverter
        Public Function GetMemStream(ByVal xml As String, ByVal width As Integer, ByVal height As Integer) As MemoryStream
            Dim ret As MemoryStream
            Dim PrefRend As New PrefModelRenderer
 
            PrefRend.SetXMLDraw(xml)
            Dim PrefStream As IStream = PrefRend.GetBitmap(width, height)
            ret = IStreamToMemoryStream(PrefStream)
            Return ret
        End Function
        Public Function GetBinaryStream(ByVal xml As String, ByVal width As Integer, ByVal height As Integer) As Byte()
            Dim ms As MemoryStream = GetMemStream(xml, width, height)
            Dim len As Integer = ms.Length
            Dim b() As Byte
            b = ms.ToArray()
            ms.Close()
            Return b
        End Function
 
        ''' 
        ''' convert the IStream into a MemoryStream 
        ''' 
        ''' 
        ''' 
        ''' 
        Private Function IStreamToMemoryStream(ByVal iStream As IStream) As MemoryStream
            Dim iBufferSize As Long
            Dim byteVector() As Byte
            Dim nSeek As _LARGE_INTEGER
            Dim nullLarge As _ULARGE_INTEGER
            Dim iBytesReaded As ULong = 1
 
            If IStream Is Nothing Then
                Return Nothing
            End If
 
            Dim memoryStream As MemoryStream = New MemoryStream()
            Dim binaryWriter As BinaryWriter = New BinaryWriter(memoryStream)
 
            'Init Variables
            iBufferSize = 2048
            nSeek.QuadPart = 0
 
            'Seek the Stream to the begin
            IStream.RemoteSeek(nSeek, 0, nullLarge)
 
            Do While iBytesReaded > 0
                'Reads the Bytes
                ReDim byteVector(2048) 'byteVector = new Byte [2048];
 
                'Read Bytes
                IStream.RemoteRead(byteVector(0), CType(iBufferSize, ULong), iBytesReaded)
 
                'And write it to the MemoryStream
                binaryWriter.Write(byteVector, 0, CType(iBytesReaded, Long))
                binaryWriter.Flush()
            Loop
 
            memoryStream.Position = 0
            Return memoryStream
        End Function
 
    End Class
End Namespace