Solved

Set crystal report image at runtime in vb.net

Posted on 2007-04-07
2
325 Views
Last Modified: 2010-04-23
Hi Experts,

I have the following code: -

Imports System.Windows
Imports CrystalDecisions.CrystalReports.Engine
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(imagepath)
        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.AddDataTable1Row(imageData)

        rpt.Load(Forms.Application.StartupPath & "\crystalreport1.rpt")
        rpt.SetDataSource(InvoiceDataSet1.Tables(0))
        CrystalReportViewer1.ReportSource = 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
0
Comment
Question by:ljhodgett
[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
  • 2
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 18869189
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 18966944
Glad i could help

mlmcc
0

Featured Post

Technology Partners: 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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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