Solved

Dynamic image in Crystal Subreport

Posted on 2010-09-13
2
484 Views
Last Modified: 2012-05-10
Hi

I've used the process of creating a dynamic image table and adding it to a crystal report at runtime many times in vb.net, but cannot get the same principle to work in an asp.net (VB) crystal report.

Basically I have a main report which will display the data, and a sub report that will contain the report title and the dynamic image.

The main report shows the data OK, but the subreport will not display the dynamic image, I just get a blank space.

Here is my code:

Public Sub CrystalDynImage() ' As DataTable

        Dim dt As New DataTable("Images")

        Dim drow As DataRow

        'Dim ds As New DataSet

        dt.Columns.Add("img", System.Type.GetType("System.Byte[]"))

        drow = dt.NewRow()

        Dim fs As FileStream

        Dim br As BinaryReader

        fs = New FileStream(Session("logopath"), FileMode.Open)

        br = New BinaryReader(fs)

        Dim imgByte(fs.Length) As Byte

        imgByte = br.ReadBytes(Convert.ToInt32((fs.Length)))

        drow(0) = imgByte

        dt.Rows.Add(drow)

        br.Close()

        fs.Close()

        rep = New ReportDocument()

       rep.Load(Server.MapPath("installations.rpt"))

        repsub = rep.OpenSubreport("report_header.rpt")

        rep.Database.Tables(0).SetDataSource(ds.Tables("installs"))

        repsub.SetDataSource(dt)
        Session("projectreport") = rep
        Me.CrystalReportViewer1.ReportSource = Session("projectreport")
        Me.CrystalReportViewer1.DataBind()
        Me.UpdatePanel2.Update()

  End Sub

Any thoughts

Thanks
0
Comment
Question by:nsfranklin
2 Comments
 
LVL 70

Accepted Solution

by:
Éric Moreau earned 250 total points
ID: 33661574
Have you tried with a simple image?

check "Feeding a custom chart" from http://www.emoreau.com/Entries/Articles/2006/10/Crystal-Reports--Part-II.aspx
0
 

Author Comment

by:nsfranklin
ID: 33661676
OK

Sorry I have resolved it. My code is good, but the link between the Database fields and the report was out of date.

I will award points as the link that emoreau gave reminded me to Verifiy the Databse i.e

Crystal Reports -> Database -> Verify Database, this resolved my issue.

Many thanks
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 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