Hi there guys really hoping for some help after searching Google for a stupidly long amount time and coming up blank.
I am using Crystal Reports 10, Asp.net 1.1, SQL Server and Visual Studio 2003 with VB.
I have an Image field in the database that I need to retrieve in to a dataset and get the image to display in crystal reports.
What I have so far is the following:
In The code behind i have something like:
Dim objImage As Images
objImage = BOL.Images.GetImage(ID)
CrystalReportDocument = New Reports.CrystalReport
Dim ObjectAdapter As new CSLA.Data.ObjectAdapter
Dim Dataset As New Reports.ReportXSD
ObjectAdapter.Fill(DataSet, "Images", objImage)
With CrystalReport
.SetDataSource(Dataset)
End With
In the Class i have a function which gets the data:
Properties:
Public Property Name() as String
get
return strName
end get
set(byval value as string)
strName = value
end set
end property
Public Property Image() as Byte ()
get
return imgImage
end get
set(byval value as Byte())
imgImage = value
end set
end property
Function:
Public Shared Function GetImage(byVal ID) As Images
Dim cmd As SqlCommand = New SqlCommand(storedProcedure, Connection)
cmd.Paramaters.Add(new SqlParamater("@intID",ID)
Connection.Open
Dim dr As SqlDataReader = CType(cmd.ExecuteReader, SqlDataReader)
If dr.HasRows Then
Dim C As Images = New Images
While dr.Read
c.Name = dr.GetString(dr.GetOrdinal("Name"))
c.Image = DirectCast(dr.GetValue(dr.GetOrdinal("Image")), Byte())
End While
dr.Close
Return c
and in the data set i have an element called Images
with two fields
Name as string and
Image as base64binary
In the report I have added the two fields (image and name), but all that is displayed
is the name and a blank image. What have I missed ?
All I can gather is I need to read the bytes, but this is where I become stuck.
Thanks in advance.
Dan