ljhodgett
asked on
Set crystal report image at runtime in vb.net
Hi Experts,
I have the following code: -
Imports System.Windows
Imports CrystalDecisions.CrystalRe ports.Engi ne
Public Class Form1
Dim rpt As New CrystalReport1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
Dim imageData() As Byte
Dim ds As New InvoiceDataSet
Dim imagepath As String = "c:\test.gif"
Dim fi As New System.IO.FileInfo(imagepa th)
Dim imgstream As System.IO.Stream = fi.OpenRead
x = CType(imgstream.Length, Integer)
ReDim Preserve imageData(x)
x = CType(fi.Length, Integer)
imgstream.Read(imageData, 0, x)
ds.DataTable1.AddDataTable 1Row(image Data)
rpt.Load(Forms.Application .StartupPa th & "\crystalreport1.rpt")
rpt.SetDataSource(InvoiceD ataSet1.Ta bles(0))
CrystalReportViewer1.Repor tSource = rpt
End Sub
End Class
What I am trying to do is place an image onto a crystal report using vb.net 2005 with the in built crystal report function. My problem is that when I place the array into the dataset the datagrid viewer that I have set to view what’s in the dataset it always shows a red x almost like internet explorer when the image can not be found. I have set the dataset field to byte(). What am I doing wrong please?
Many Thanks
Lee
I have the following code: -
Imports System.Windows
Imports CrystalDecisions.CrystalRe
Public Class Form1
Dim rpt As New CrystalReport1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x As Integer
Dim imageData() As Byte
Dim ds As New InvoiceDataSet
Dim imagepath As String = "c:\test.gif"
Dim fi As New System.IO.FileInfo(imagepa
Dim imgstream As System.IO.Stream = fi.OpenRead
x = CType(imgstream.Length, Integer)
ReDim Preserve imageData(x)
x = CType(fi.Length, Integer)
imgstream.Read(imageData, 0, x)
ds.DataTable1.AddDataTable
rpt.Load(Forms.Application
rpt.SetDataSource(InvoiceD
CrystalReportViewer1.Repor
End Sub
End Class
What I am trying to do is place an image onto a crystal report using vb.net 2005 with the in built crystal report function. My problem is that when I place the array into the dataset the datagrid viewer that I have set to view what’s in the dataset it always shows a red x almost like internet explorer when the image can not be found. I have set the dataset field to byte(). What am I doing wrong please?
Many Thanks
Lee
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
mlmcc