yireh
asked on
DYNAMIC IMAGE TO CRYSTAL REPORTS
I have the following code but the image is not showing in the report.
Private mdsData As DataSet
Private mrptDoc As New ReportDocument
Private Sub CreateDataSet()
mdsData = New DataSet("CardData")
Using dt As New DataTable("CardData")
dt.Columns.Add("Foto", System.Type.GetType("Syste m.Byte[]") )
dt.Columns.Add("FullName", GetType(String))
dt.Columns.Add("NumSocio", GetType(String))
dt.Columns.Add("TipoSocio" , GetType(String))
dt.Columns.Add("SinceDate" , GetType(String))
'Save the canadian flag into a Memory Stream object
'and from there to an array of byte
Dim fs As New FileStream("l:\pr.gif", FileMode.Open) ' create a file stream
Dim br As New BinaryReader(fs) ' create binary reader
Dim row As DataRow
' create a new datarow
row = dt.NewRow()
' set country field and image field
row("Foto") = br.ReadBytes(br.BaseStream .Length)
row("FullName") = "John Doe"
row("NumSocio") = "123456"
row("TipoSocio") = "ELITE"
row("SinceDate") = "2/01/2002"
' add this row to the table
dt.Rows.Add(row)
' clean up
br = Nothing
fs = Nothing
mdsData.Tables.Add(dt)
End Using
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
CreateDataSet()
mdsData.WriteXmlSchema(My. Computer.F ileSystem. SpecialDir ectories.T emp & "\CardData.xsd")
'Load the standalone report
mrptDoc.Load("C:\cfass\bin \Debug\rep ortes\rptC ard.rpt")
'Pass the dataset to the report
mrptDoc.SetDataSource(mdsD ata)
'Set the values of the parameters
mrptDoc.SetParameterValue( "BarCodeNu mber", "123456")
mrptDoc.SetParameterValue( "ClubName" , "CURRENT CLUB")
'Pass the Report Document object to the viewer
CrystalReportViewer1.Repor tSource = mrptDoc
End Sub
Private mdsData As DataSet
Private mrptDoc As New ReportDocument
Private Sub CreateDataSet()
mdsData = New DataSet("CardData")
Using dt As New DataTable("CardData")
dt.Columns.Add("Foto", System.Type.GetType("Syste
dt.Columns.Add("FullName",
dt.Columns.Add("NumSocio",
dt.Columns.Add("TipoSocio"
dt.Columns.Add("SinceDate"
'Save the canadian flag into a Memory Stream object
'and from there to an array of byte
Dim fs As New FileStream("l:\pr.gif", FileMode.Open) ' create a file stream
Dim br As New BinaryReader(fs) ' create binary reader
Dim row As DataRow
' create a new datarow
row = dt.NewRow()
' set country field and image field
row("Foto") = br.ReadBytes(br.BaseStream
row("FullName") = "John Doe"
row("NumSocio") = "123456"
row("TipoSocio") = "ELITE"
row("SinceDate") = "2/01/2002"
' add this row to the table
dt.Rows.Add(row)
' clean up
br = Nothing
fs = Nothing
mdsData.Tables.Add(dt)
End Using
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
CreateDataSet()
mdsData.WriteXmlSchema(My.
'Load the standalone report
mrptDoc.Load("C:\cfass\bin
'Pass the dataset to the report
mrptDoc.SetDataSource(mdsD
'Set the values of the parameters
mrptDoc.SetParameterValue(
mrptDoc.SetParameterValue(
'Pass the Report Document object to the viewer
CrystalReportViewer1.Repor
End Sub
try with a bitmap first (before trying a GIF). not all image formats are available.
ASKER
No, the .bmp is not working.
have you tried the sample I have in my article of October 2006 from http://emoreau.s2i.com/ ?
ASKER
Eric, looking your sample. Your report have the image in IBlobFieldObject and my report have the image in a IFieldObject but not have the option to change the object type.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes,
It's working. The problem is with the schema.
Thnaks Eric.
It's working. The problem is with the schema.
Thnaks Eric.
http://www.thescripts.com/forum/thread103039.html
Thad