Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Closed Thread
 
Thread Tools Display Modes
  #1 (permalink)  
Old September 24th, 2004, 05:11 AM
Registered User
 
Join Date: Sep 2004
Location: Batam Island, Riau, Indonesia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Picture in crystal report


Dear all,
I have a field in the database. It uses to store path of picture,
I want to show the picture suit the path in the database

but i don't khow how to do that

anyone help me ?

chen_an
__________________
chen_an
  #2 (permalink)  
Old October 7th, 2004, 03:22 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Canada
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik Send a message via Skype™ to melvik
Default

u just need to select that field(s) from Table & then put that Pic field into ur Report.

Keep in touch.

Always:),
Hovik Melkomian.
  #3 (permalink)  
Old October 8th, 2004, 12:17 AM
Registered User
 
Join Date: Sep 2004
Location: Batam Island, Riau, Indonesia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default


but i didn't store the picture into database, i only store the path of the picture ....

chen' ;)

chen_an
  #4 (permalink)  
Old October 13th, 2004, 09:25 AM
Authorized User
 
Join Date: Oct 2004
Location: Albuquerque, NM, USA.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In the report designer, do a right click and select "insert", then choose your object type. From there you will be able to browse to the picture file. Select it to insert it.

  #5 (permalink)  
Old October 25th, 2004, 01:34 PM
Registered User
 
Join Date: Oct 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

damn retards, what he is trying to do is tell crystal reports to load an image from a path he is goin to retrieve from a database...

i dont know the answer to that either and i need to do it as well.

can anyone else help us?

  #6 (permalink)  
Old November 9th, 2004, 03:40 PM
Registered User
 
Join Date: Nov 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm also interested in this solution, got a path to images in database and want to print out the images.

Thanks ... Chad

  #7 (permalink)  
Old November 9th, 2004, 04:01 PM
Authorized User
 
Join Date: Oct 2004
Location: Albuquerque, NM, USA.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You will not be able to tell Crystal Reports to load an image from a path retrieved in a database. You can, however, place that field into a hyperlink and access it that way.

By the way, RobZ, NOBODY on a forum will want to respond kindly to you when you've called them a "Damn retard." If you intend to get anywhere with forums, treat people with respect and keep those kind of opinions to yourself. I am not a "Damn retard" and I take great offense at your comment.

  #8 (permalink)  
Old November 10th, 2004, 11:08 AM
Authorized User
 
Join Date: Oct 2004
Location: Albuquerque, NM, USA.
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've just been reviewing Brian Bischoff's excellent book "Crystal Reports .NET Programming". ON pages 370-373 he goes into detail of a workaround on this one. It's too complex to post, and I haven't attempted it. He begins by pointing out that methods in previous versions of Crystal Reports that allowed it aren't available in .NET.

If you haven't found his book, I HIGHLY recommend it:

http://www.crystalreportsbook.com/

I bought my copy at Amazon.com for $28.21, including shipping.


  #9 (permalink)  
Old May 2nd, 2006, 10:49 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I decided to write this article after realizing how many people have trouble with letting the user upload an image to their crystal report. Say for an example if the user wants to change or upload their logo onto the crystal report. How can you do this? How the developers can provide this facility to the users?

We all know that users cannot customize crystal reports much. Once the crystal report is generated, users don't have much of a choice to change the fields as they wish. This article is going to demonstrate how can the user upload or change an image on the crystal report.

This is actually a very simple example. Even if you have a novice knowledge about Crystal reports you will be able to understand how this works. I am using Crystal reports 11 for this demonstration.

To start off from the beginning, create a new windows application and add a crystal report viewer and a browse button.

This browse button will allow the user to add an image to the report. Add a crystal report into your project.

Report Schema:

We all know that we need to provide a schema for the crystal repot. Here is an XML view of the report schema that we are going to supply for the report.

<?xml version="1.0" standalone="yes"?>
          <xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-
          microsoft-com:xml-msdata">
                  <xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:Locale="en-AU">
                       <xs:complexType>
                           <xs:choice maxOccurs="unbounded">
                              <xs:element name="Images">
                                  <xs:complexType>
                                       <xs:sequence>
                                           <xs:element name="path" type="xs:string" minOccurs="0" />
                                           <xs:element name="image" type="xs:base64Binary" minOccurs="0" />
                                       </xs:sequence>
                                  </xs:complexType>
                              </xs:element>
                           </xs:choice>
                       </xs:complexType>
                  </xs:element>
          </xs:schema>

BLOB field:

In order to add an image to the crystal report (considering the image field is coming from the database) we need to have a BLOB field in the schema. When you want to store images, documents or different custom types in the database you use a BLOB field. BLOB stands for Binary Large Object.

<xs:element name="path" type="xs:string" minOccurs="0" />
<xs:element name="image" type="xs:base64Binary" minOccurs="0" />

If you inspect this schema we can see that we have a table called "Images" and two columns "path" and "image". "image" column is type Base64 Binary. This is our BLOB field.What we are going to do in our program is when the user selects the image to upload we store that image in a BLOB field as a stream of bytes and then supply that dataset to the report.

CreateTable() method will illustrate how to generate this schema in the program.

Generating the schema for the report:

There are other ways you can create the schema but this will give you a clearer idea about the column fields.

Creating the table:

private void CreateTable()

{

          //create a new data set.

          this.DsImages = new DataSet();

          //create a new table with two columns and add the table to the
      dataset

DataTable ImageTable = new DataTable("Images");

          //in here the "path" column is not really needed. Image column is
      just enough.

ImageTable.Columns.Add(new DataColumn("path",typeof(string)));

          //Important note

          //Note the type of the image column. You want to give this column
      as a blob field to the crystal report.

          //therefore define the column type as System.Byte[]

          ImageTable.Columns.Add(new DataColumn("image",typeof(System.Byte[])));

          this.DsImages.Tables.Add(ImageTable);

}

If you notice the "image" column you can see that the type of that column is System.Byte[]. This is pretty straight forward. Just create a table with two columns. Then add it to the dataset. Now you can create the schema using this line:

this.DsImages.WriteXmlSchema(@"c:\temp\ImagesSchem a.xsd");

Once we have the schema ready we can provide it to the crystal report.




In the field explorer we can see Images table and the two columns path and image. When you drag the image column onto the report you can see the type of that field is IBlobFieldObject. These fields will read a stream of bytes and convert it back to an image. So our task is pretty much done. The code below shows you how it can save the image as a stream of bytes in the BLOB field.

private void openFileDialog1_FileOk(object sender, System.ComponentModel.CancelEventArgs e)

{

          try

          {

                   //get the image file into a stream reader.

                   FileStream FilStr = new FileStream(this.openFileDialog1.FileName, FileMode.Open);

                    BinaryReader BinRed = new BinaryReader(FilStr);

                   //Adding the values to the columns

                   // adding the image path to the path column

                   DataRow dr = this.DsImages.Tables["images"].NewRow();

                   dr["path"] = this.openFileDialog1.FileName;

                   //Important:

                   // Here you use ReadBytes method to add a byte array of the image stream.

                   //so the image column will hold a byte array.

                   dr["image"] = BinRed.ReadBytes((int)BinRed.BaseStream.Length);

                   this.DsImages.Tables["images"].Rows.Add(dr);

                   FilStr.Close();

                   BinRed.Close();

                   //create the report object

                   DynamicImageExample DyImg = new DynamicImageExample();

                   // feed the dataset to the report.

                   DyImg.SetDataSource(this.DsImages);

                   this.crystalReportViewer1.ReportSource = DyImg;

          }

          catch(Exception er)

          {

                   MessageBox.Show(er.Message,"Error");

          }

}

You write this in the FileOk method of the openFileDialog. You use the BinaryReader.ReadBytes method to read the byte array.

dr["image"] = BinRed.ReadBytes((int)BinRed.BaseStream.Length);

If you inspect this line of code you can see that we have assigned a byte array in the "image" column of the table. This byte array is the image that the user selected. So when you supply this dataset to the crystal report the IBlobFieldObject in the report will convert this byte array back to the image.

That is all you need to understand in this program. Below I have listed all the important steps you need to understand.

    * User selects an image.
    * We save the image in a blob field as a stream of bytes.
    * Supply the dataset to the report which contains the BLOB field.
    * Report will convert the stream of bytes back to the image and show it.

Conclusion:

Using this example in we can give the user to customize the images they want to upload to the report. This would be a good implementation in situations like if the users want to change the images on the report or upload their logos by them selves. Users don't have to contact their software development team every time they want to change an image on the report. Customizing the crystal report at the user end is not possible when it comes to moving the fields across the report or adding new fields. This article only helps you to understand how you can upload an image at run time. It does not tell how you can customize a crystal report at runtime. I hope you understood the concept of this article.

Just download this program and try it. Make sure you have Crystal Reports 11. The code I have written here is basic. You shouldn't have any problems understanding this.

  #10 (permalink)  
Old May 22nd, 2006, 03:41 AM
Registered User
 
Join Date: May 2006
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 I m generating Barcode image which i want on my crystal report...
This is my code ......

 Dim ds As New dsProductTag
        Dim rpt As New rptProdTag

        Dim bc As C1BarCode

        Me.SqlConnection1.ConnectionString = System.Configuration.ConfigurationSettings.AppSett ings("sqlConnString")
        Me.SqlConnection1.Open()

        Me.SqlSelectCommand1.CommandText = "SELECT * FROM PRMAProductUPCDetail where VarProductId='1'"
        Me.SqlSelectCommand1.Connection = Me.SqlConnection1

        Me.SqlDataAdapter1.SelectCommand = Me.SqlSelectCommand1

        Me.SqlDataAdapter1.Fill(ds)

        For Each dr As DataRow In ds.Tables(0).Rows
            bc = New C1BarCode
            bc.CodeType = CodeTypeEnum.Ean13
            bc.Text = CStr(dr("VarUPC"))
            bc.ShowText = True

            dr("ImgProductTag") = bc.Image
        Next

          rpt.SetDataSource(ds)
        CrystalReportViewer1.ReportSource = rpt

        Me.SqlConnection1.Close()

 i already have image column in my dataset table
i ve drag the image field on the report n its showing BLOB type but on execution it is not shoiwing the image only its space cross image..
can any one help me...
what i m missing.

Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report picture box brodavid2005 VB Components 2 July 23rd, 2007 06:38 AM
picture on crystal report 8.5 khay_6 Access VBA 0 March 7th, 2005 10:26 PM
picture on crystal report 8.5 khay_6 Access VBA 0 February 22nd, 2005 08:23 PM
Background picture for Crystal Report pavel Pro VB 6 0 October 9th, 2003 09:33 AM
Background Picture for my crystal report pavel VB How-To 0 September 19th, 2003 01:59 PM



All times are GMT -4. The time now is 05:31 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.