Click here to Skip to main content
13,197,105 members (51,281 online)
Click here to Skip to main content
Add your own
alternative version


73 bookmarked
Posted 29 Oct 2007

Image in Crystal Reports

Rate this:
Please Sign up or sign in to vote.
This is sample small project to display image in crystal report
Screenshot - ImgInReport.gif


This article will display the image in crystal report viewrBackground

Using the code

Simply open the source code in 2003.

    try { 
        // here i have define a simple datatable inwhich image will recide 
        DataTable dt = new DataTable(); 
        // object of data row 
        DataRow drow; 
        // add the column in table to store the image of Byte array type 
        dt.Columns.Add("Image", System.Type.GetType("System.Byte[]")); 
        drow = dt.NewRow; 
        // define the filestream object to read the image 
        FileStream fs; 
        // define te binary reader to read the bytes of image 
        BinaryReader br; 
        // check the existance of image 
        if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg")) { 
            // open image in file stream 
            fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "10157.Jpg", FileMode.Open); 
        else { 
            // if phot does not exist show the nophoto.jpg file 
            fs = new FileStream(AppDomain.CurrentDomain.BaseDirectory + "NoPhoto.jpg", FileMode.Open); 
        // initialise the binary reader from file streamobject 
        br = new BinaryReader(fs); 
        // define the byte array of filelength 
        byte[] imgbyte = new byte[fs.Length + 1]; 
        // read the bytes from the binary reader 
        imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length))); 
        drow(0) = imgbyte; 
        // add the image in bytearray 
        // add row into the datatable 
        // close the binary reader 
        // close the file stream 
        CrystalReport1 rptobj = new CrystalReport1(); 
        // object of crystal report 
        // set the datasource of crystalreport object 
        CrystalReportViewer1.ReportSource = rptobj; 
        //set the report source 
    catch (Exception ex) { 
        // error handling 
        Interaction.MsgBox("Missing 10157.jpg or nophoto.jpg in application folder"); 
// run the application to view image in report 

Remember if you are using c# the paste the above code in button click event

Points of Interest

In this article you will be also able to convert the image into byte array


In this project after clicking the button the action are performed you are free to modify as per your requirement
Feel free for any querrrrrries.

enjoy .net


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

TangoCharli (Anant Tiwari)
Software Developer (Senior) Avenues Technologies Pvt Ltd
India India
MCTS Microsoft Certified Technology Specialist
Computer Engineer

You may also be interested in...


Comments and Discussions

AnswerRe: Blob Field [modified] Pin
IndomitablePhoenix11-Jan-11 7:56
memberIndomitablePhoenix11-Jan-11 7:56 
GeneralMitico Pin
panicemi8-Jun-10 4:41
memberpanicemi8-Jun-10 4:41 
GeneralImage in Crystal Reports Pin
Huseyin Altindag16-Feb-10 9:12
memberHuseyin Altindag16-Feb-10 9:12 
GeneralRe: Image in Crystal Reports without logon to database popup Pin
Huseyin Altindag20-Feb-10 9:34
memberHuseyin Altindag20-Feb-10 9:34 
AnswerApply by use sub report no need to implement BLOB field Pin
pakpoompok10-Feb-10 15:43
memberpakpoompok10-Feb-10 15:43 
GeneralBlob Field Pin
Member 44854195-Dec-09 13:46
memberMember 44854195-Dec-09 13:46 
GeneralRe: Blob Field Pin
Member 607717516-Dec-09 2:49
memberMember 607717516-Dec-09 2:49 
GeneralRe: Blob Field Pin
Member 448541928-Dec-09 18:35
memberMember 448541928-Dec-09 18:35 
Is there anhyone to solve my problem .its urgent.i have to complete my project with in a rest of all project have completed.i have only problem with dis blob field
AnswerRe: Blob Field - Answered Pin
IndomitablePhoenix11-Jan-11 8:06
memberIndomitablePhoenix11-Jan-11 8:06 
Generalblob field object [modified] Pin
apol524 p4-Nov-09 14:22
memberapol524 p4-Nov-09 14:22 
AnswerRe: blob field object - Answered Pin
IndomitablePhoenix11-Jan-11 8:09
memberIndomitablePhoenix11-Jan-11 8:09 
GeneralGood job! Pin
Nguyennamhs27-Oct-09 21:48
memberNguyennamhs27-Oct-09 21:48 
Generalhi Pin
shrimast25-Sep-09 21:38
membershrimast25-Sep-09 21:38 
GeneralDatabase Login Error Pin
MATTXtwo26-May-09 19:19
memberMATTXtwo26-May-09 19:19 
AnswerRe: Database Login Error - possible solution Pin
IndomitablePhoenix11-Jan-11 8:12
memberIndomitablePhoenix11-Jan-11 8:12 
QuestionHow to display image in crystal report VS 2005 Pin
kiddsx4u17-Apr-09 9:42
memberkiddsx4u17-Apr-09 9:42 
AnswerRe: How to display image in crystal report VS 2005 Pin
Dan Duggan26-Nov-09 6:42
memberDan Duggan26-Nov-09 6:42 
GeneralRe: How to display image in crystal report VS 2005 Pin
krunal108915-Sep-10 10:30
memberkrunal108915-Sep-10 10:30 
AnswerRe: How to display image in crystal report VS 2005 - two images at once - possible solutions Pin
IndomitablePhoenix11-Jan-11 8:17
memberIndomitablePhoenix11-Jan-11 8:17 
GeneralRe: How to display image in crystal report VS 2005 Pin
rajnish2patel20-Dec-11 20:31
memberrajnish2patel20-Dec-11 20:31 
GeneralAccess denied exception Pin
nihad aliyev26-Nov-08 1:36
membernihad aliyev26-Nov-08 1:36 
AnswerRe: Access denied exception - FileMode for FileStream Pin
IndomitablePhoenix11-Jan-11 8:29
memberIndomitablePhoenix11-Jan-11 8:29 
GeneralGreat !!! Pin
lcsistemas8-Oct-08 13:29
memberlcsistemas8-Oct-08 13:29 
Questionhow to make Image object on crystal report Pin
naveed8812-Sep-08 2:08
membernaveed8812-Sep-08 2:08 
AnswerRe: how to make Image object on crystal report Pin
hugoflores9-Apr-09 5:13
memberhugoflores9-Apr-09 5:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171020.1 | Last Updated 30 Oct 2007
Article Copyright 2007 by TangoCharli (Anant Tiwari)
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid