Click here to Skip to main content
14,092,036 members
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

QuestionQuery about your post Pin
Member 1326593018-Jun-17 7:50
memberMember 1326593018-Jun-17 7:50 
Questionhi TangoCharli I have question for your post (Image in Crystal Reports) Pin
Sraj Muneer12-May-17 10:52
memberSraj Muneer12-May-17 10:52 
PraiseThank you Pin
JD.Naik22-Apr-17 3:38
memberJD.Naik22-Apr-17 3:38 
Questionttx file Pin
Member 1057908431-Mar-17 4:30
memberMember 1057908431-Mar-17 4:30 
QuestionIt is possible to choose the location where the image will be added no rpt ? Pin
bydario1-Jun-16 8:09
memberbydario1-Jun-16 8:09 
QuestionAdding image from path specified Pin
Member 1207720221-Oct-15 10:42
memberMember 1207720221-Oct-15 10:42 
Questionview jpg image pdf using crystal report Pin
Member 108569972-Aug-15 17:49
memberMember 108569972-Aug-15 17:49 
QuestionNow working Pin
heemanshu bhalla25-Oct-13 4:17
memberheemanshu bhalla25-Oct-13 4:17 
QuestionNot working Pin
heemanshu bhalla25-Oct-13 0:23
memberheemanshu bhalla25-Oct-13 0:23 
GeneralMy vote of 5 Pin
Member 937103828-Jun-13 0:13
memberMember 937103828-Jun-13 0:13 
GeneralMy vote of 5 Pin
raj ch28-Jan-13 22:12
memberraj ch28-Jan-13 22:12 
GeneralThnk u Pin
kiransolkar24-Dec-12 21:05
memberkiransolkar24-Dec-12 21:05 
QuestionBlob Field Pin
Raghavendra Rao 55815-Nov-12 1:01
memberRaghavendra Rao 55815-Nov-12 1:01 
Questiondatabase expert query Pin
Nikhil S Soni23-Oct-12 0:40
memberNikhil S Soni23-Oct-12 0:40 
AnswerRe: database expert query Pin
kiransolkar24-Dec-12 20:41
memberkiransolkar24-Dec-12 20:41 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey23-Feb-12 19:13
professionalManoj Kumar Choubey23-Feb-12 19:13 
Generalwant image to be shown on special point of Report Pin
edinazem2-May-11 21:34
memberedinazem2-May-11 21:34 
GeneralMy vote of 5 Pin
sohebrapati19-Mar-11 1:31
groupsohebrapati19-Mar-11 1:31 
AnswerSimple Solution - BlobField - How answered Pin
IndomitablePhoenix10-Jan-11 12:02
memberIndomitablePhoenix10-Jan-11 12:02 
Generalpdf too large Pin
yi23-Oct-10 23:44
memberyi23-Oct-10 23:44 
AnswerRe: pdf too large [modified] Pin
IndomitablePhoenix11-Jan-11 7:38
memberIndomitablePhoenix11-Jan-11 7:38 
Generali want image should come from database from msaccess Pin
krunal108915-Sep-10 8:45
memberkrunal108915-Sep-10 8:45 
AnswerRe: i want image should come from database from msaccess Pin
IndomitablePhoenix11-Jan-11 7:55
memberIndomitablePhoenix11-Jan-11 7:55 
GeneralBlob Field Pin
enzo583-Aug-10 19:44
memberenzo583-Aug-10 19:44 
AnswerRe: Blob Field [modified] Pin
IndomitablePhoenix11-Jan-11 7:56
memberIndomitablePhoenix11-Jan-11 7:56 

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 | Cookies | Terms of Use | Mobile
Web01 | 2.8.190518.1 | Last Updated 30 Oct 2007
Article Copyright 2007 by TangoCharli (Anant Tiwari)
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid