Show Dynamic Image on CrystalReport

Last post 07-07-2009 5:25 AM by jeyaseelan@ajsquare.net. 5 replies.

Sort Posts:

  • Show Dynamic Image on CrystalReport

    06-23-2009, 7:52 AM

    Hi All,

           I am using VS05 + SQL Server 2005 + CrystalReport.

    I have created an application which contains crystalReport. The CrystalReport contains Company Logo. Uptil now it is PictureBox, which contains picture. But it is not dynamic.

    I want this comapny logo should from database. If the logo changes from database it should reflect on the crystalreport.   How to save the image in SQL Database and reflect it to crystalreport.

    The procedure in c# is appriciated.

    Thanks in advance.

  • Re: Show Dynamic Image on CrystalReport

    06-25-2009, 3:10 AM
    • Member
      24 point Member
    • btough
    • Member since 05-08-2009, 10:02 AM
    • India
    • Posts 52

    Hi,

    First read your image file data into byte[] like -

    String fullFilePath = FilePath + FileName;


    FileStreamfs1 = new FileStream(fullFilePath, FileMode.Open, FileAccess.Read);

    BinaryReader br1 = new BinaryReader(fs1);

    byte[] bt1 = br1.ReadBytes((int)fs1.Length);

    fs1.close();

    (I am not sure about how to add imagedata into database. But it should be something like below. Experts please make me clear if I am wrong)

    Create one column in database as ImageData with Varbinary(max) datatype.

    Establish connection with database programaticaly. Then add this bt1 array value into database using INSERT query. Now create a dataset with column as DataColumn1 (datatype System.Byte[]). Set this dataset as the datasource of the CrystalReport, then drag and drop your DataColumn1 from dataset into Crystal Report. Fill Dataset by the query result using SqlDataAdaptor and SqlCommand object.

    Hope this will work for you.

    Thanks,

    -YogeshP.

  • Re: Show Dynamic Image on CrystalReport

    06-29-2009, 9:27 AM

    Santoshkhadkebeed this is wonderful article regarding your doubt check this http://www.neodynamic.com/ND/FaqsTipsTricks.aspx?tabid=66&prodid=1&sid=69

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: Show Dynamic Image on CrystalReport

    07-07-2009, 4:58 AM
    • Member
      2 point Member
    • camadanmohan
    • Member since 07-07-2009, 6:36 AM
    • Posts 1

    Hi to all,

         my name is madan and i'm new to these group. i faced the problem to store the image into bytes atlost i find and saved in table.

    now i got one problem how to show the image which in table which was in bynary form i tryed in several ways but i'did'nt  get plz any one help me

    i created dataset in that i used column as image and i set the property as bytes and in database the datatype was byest[] it was mismatching while retriving the data

    plz any one help me


    thank in advance.

    bye madan

  • Re: Show Dynamic Image on CrystalReport

    07-07-2009, 5:21 AM

    Madhan, Thanks for your post.

    Actually in sql server you have to set the datatype as Image to store the images.

    This is the way to add the image into sql LINK1 LINK2

    This is the way to add the image into Crystal Report:

    From the DataSet.xsd file you have to drag and drop the columns. For image you have to add BitMapObject within the report by Right Click on report-->Add object-->select Bitmap click ok.

    and set the datatype of this column as byte[] (also you should check the image column datatype should be byte[] in DataSet file). Then you have to to execute your query and fill the records into DataTable/DataSet object then assign this in to CrystalReport object then set that crystal report object into CrystalReportViewer control.

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
  • Re: Show Dynamic Image on CrystalReport

    07-07-2009, 5:25 AM

    Madhan, Thanks for your post.

    Actually in sql server you have to set the datatype as Image to store the images.

    This is the way to add the image into sql LINK1 LINK2

    This is the way to add the image into Crystal Report:

    From the DataSet.xsd file you have to drag and drop the columns. For image you have to add BitMapObject within the report by Right Click on report-->Add object-->select Bitmap click ok.

    and set the datatype of this column as byte[] (also you should check the image column datatype should be byte[] in DataSet file). Then you have to to execute your query and fill the records into DataTable/DataSet object then assign this in to CrystalReport object then set that crystal report object into CrystalReportViewer control.

    But one thing Crystal Report doesnt support GIF file so try to use JPEG file.

    Any doubts please feel free to ask me.

    If this post is answer of your question then don't forgot to Click Mark As Answer.

    Thanks & Regards,
    J.Jeyaseelan
Page 1 of 1 (6 items)