Solved

DYNAMIC IMAGE TO CRYSTAL REPORTS

Posted on 2006-11-13
7
741 Views
Last Modified: 2007-12-19
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("System.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.FileSystem.SpecialDirectories.Temp & "\CardData.xsd")
        'Load the standalone report
        mrptDoc.Load("C:\cfass\bin\Debug\reportes\rptCard.rpt")

        'Pass the dataset to the report
        mrptDoc.SetDataSource(mdsData)

        'Set the values of the parameters
        mrptDoc.SetParameterValue("BarCodeNumber", "123456")
        mrptDoc.SetParameterValue("ClubName", "CURRENT CLUB")

        'Pass the Report Document object to the viewer
        CrystalReportViewer1.ReportSource = mrptDoc
    End Sub
0
Comment
Question by:yireh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:riyazthad
ID: 17931131
I think you need to use typed dataset and crystal report dynamic chat. I hope this may help you.

http://www.thescripts.com/forum/thread103039.html

Thad
0
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17931826
try with a bitmap first (before trying a GIF). not all image formats are available.
0
 
LVL 1

Author Comment

by:yireh
ID: 17931964
No, the .bmp is not working.
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 70

Expert Comment

by:Éric Moreau
ID: 17932006
have you tried the sample I have in my article of October 2006 from http://emoreau.s2i.com/ ?
0
 
LVL 1

Author Comment

by:yireh
ID: 17932265
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.
0
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 17932404
can it be your schema that is wrong?
0
 
LVL 1

Author Comment

by:yireh
ID: 17932523
Yes,

It's working. The problem is with the schema.

Thnaks Eric.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question