[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Dynamic Content into Crystal Report

Posted on 2004-11-01
9
Medium Priority
?
558 Views
Last Modified: 2008-02-01
Hello:

Is there a way to put a "placeholder" (if you will) in CR, that would hold an image created during runtime by VB.Net.

In other words, a big empty spot in the CR designer, that would be filled by a picture that was created by VB.Net and inserted maybe via bitstream.

Please give me some ideas!!!

Thanks in advance.
0
Comment
Question by:jrandallsexton
[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
  • 6
  • 2
9 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 12466130
Here is how to do that from VB6.  It must be saved as a bmp

http://support.businessobjects.com/communityCS/FilesAndUpdates/cr9_vb_rdc_loadpic.exe.asp

I'll look for a .net example

mlmcc
0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12466268
I don't have VB6 installed and the conversion wizard bombed.

I really need a .Net example.

Thanks!!!
0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12467214
What about storing an image in SQL server, and simply pulling from image datatype into report?  I tried it, but couldn't make it work.  Anyone ever do that before?
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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 10

Accepted Solution

by:
ebolek earned 1500 total points
ID: 12468006
this is what you have to do .I have already anwered this question so other than explain it here go to the link. It will help you

http://www.experts-exchange.com/Databases/Crystal_Reports/Q_21130269.html

Regards
Emre
0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12474263
ebolek:

I appreciate the link you posted.  However, simply posting code doesn't always help.

What did you do? Did you create a strongly typed dataset and design the Crystal Report from the XML file you produced from the dataset?

Looks like your dataset is:
PicNumber Integer
ImagePath String
Image Byte[]

Is that correct?

How did you get Crystal to display an image instead of an empty blob field?  I ask this because I tried something similar by storing images in SQL server using an Image datatype.  I pointed the report to the table and when it came back, there were empty squares where the pictures should have been.

0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12474997
ebolek:

I got it working.  

For everyone else: Execute your code so that the XML file creates, then base your report off of the XML file. When you go to run the report 'for real', simply use: myReport.SetDataSource(myDataSet)

The VB.Net code is posted below:

***************************************************************
                    Dim myDataset As New DataSet
                    Dim myDataTable As DataTable
                    Dim myDataRow As DataRow
                    myDataTable = New DataTable
                    Dim myDataColumn As New DataColumn
                    myDataColumn = New DataColumn("PicNumber", Type.GetType("System.Int32"))
                    myDataTable.Columns.Add(myDataColumn)
                    myDataColumn = New DataColumn("ImagePath", Type.GetType("System.String"))
                    myDataTable.Columns.Add(myDataColumn)
                    myDataRow = myDataTable.NewRow
                    myDataRow("PicNumber") = 1
                    myDataRow("ImagePath") = "C:\test.bmp"
                    myDataTable.Rows.Add(myDataRow)
                    myDataset.Tables.Add(myDataTable)
                    'Add the image column to the table
                    AddImageColumn(myDataTable, "Image")
                    myDataset.WriteXmlSchema("C:\Image.xsd")
                    'Load the images into the dataset
                    LoadAllImages(myDataTable, "ImagePath", "Image")
                    crpCR1 = New DundasTest
                    crpCR1.setdatasource(myDataset)
***************************************************************

    Public Sub AddImageColumn(ByVal myDataTable As DataTable, ByVal fieldName As String)
        Try
            Dim myDataColumn As New DataColumn(fieldName, Type.GetType("System.Byte[]"))
            myDataTable.Columns.Add(myDataColumn)
        Catch ex As Exception
            MsgBox(Err.Description & " - " & ex.InnerException.ToString)
        End Try
    End Sub

    Public Sub LoadAllImages(ByVal myDataTable As DataTable, ByVal filePathField As String, ByVal ImageField As String)
        Try
            Dim myDatarow As DataRow
            For Each myDatarow In myDataTable.Rows
                LoadImage(myDatarow, ImageField, myDatarow(filePathField).ToString)
            Next
        Catch ex As Exception
            MsgBox(Err.Description & " - " & ex.InnerException.ToString)
        End Try
    End Sub

    Public Sub LoadImage(ByVal myDataRow As DataRow, ByVal ImageField As String, ByVal FilePath As String)
        Try
            FilePath = "C:\test.bmp"
            Dim fs As New IO.FileStream(FilePath, IO.FileMode.Open)
            Dim image() As Byte
            Dim br As New IO.BinaryReader(fs)
            image = br.ReadBytes(CInt(fs.Length))
            myDataRow(ImageField) = image
            fs.Close()
            br.Close()
        Catch ex As Exception
            MsgBox(ex.InnerException.ToString)
        End Try
    End Sub
0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12475020
By the way, I graded the answer as a "B" because I felt that ebolek could have done a better job explaining what he was doing in his other post.
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12475452
whatever you feel but this should have saved you from long hours of trying to find how to do this.
0
 
LVL 4

Author Comment

by:jrandallsexton
ID: 12475787
I'm not denying that you saved me MUCH time.  Just after I read through your other post, I felt that you didn't do a very good job explaining.  You pretty much put the code out there and said 'here it is'.  Anyway.  Good solution and I appreciate your help.  You still got 1500 pts.

Thanks again.
0

Featured Post

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.

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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