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
Solved

DYNAMIC IMAGE TO CRYSTAL REPORTS

Posted on 2006-11-13
7
731 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
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

829 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