Solved

DYNAMIC IMAGE TO CRYSTAL REPORTS

Posted on 2006-11-13
7
698 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
  • 3
  • 3
7 Comments
 
LVL 6

Expert Comment

by:riyazthad
Comment Utility
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 69

Expert Comment

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

Author Comment

by:yireh
Comment Utility
No, the .bmp is not working.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 69

Expert Comment

by:Éric Moreau
Comment Utility
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
Comment Utility
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 69

Accepted Solution

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

Author Comment

by:yireh
Comment Utility
Yes,

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

Thnaks Eric.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now