How to display images from SQL Server to Crystal Report?

In this article I have explained about how to display stored images from SQL Server table “image” field to Crystal Report. Here in this example I have connected crystal report with XML Dataset fields. I have “Student” table like two fields sname and simage.

In my previous article I had explained about how to store images into SQL Server table "image" field.

Now I have explained about how to display that images from SQL server table to Crystal Report.

How to create XML dataset with SQL Server table details?
Create dataset: Right Click your project name -> ADD new Item ->select data set (DataSet1.xsd)
Then right click of that dataset and add new column (for your field names, types) as same like in the SQL Server table field names.

How to change XML Dataset field as image?
After creating XML dataset fields then right click of the "simage" field in the XML dataset and choose properties -> change property as Byte "System.Byte[]".

How to connect dataset and CrystalReport Page in ASP.Net?
Right Click your project name -> ADD new Item ->Choose Crystal report and put name (sample name like this CrystalReport1.rpt).
Choose Field explorer in Left side and right click database Field -> Choose Database expert->choose new ADO.Net connection in tree and choose your dataset path and click finish.
Then your fields are displayed in field explorer drag and drop in to crystal report.

Note: If you change property as image in XML data set then only images are displayed in crystal report otherwise not displayed.

How to bind records in crystal report?

protected void Page_Load(object sender, EventArgs e)
if (!Page.IsPostBack)
sname = Request.QueryString["sname"];
if (sname == null || sname=="")
query = "select * from student";
query = "select * from student where sname='" + sname + "'";
sqlcmd = new SqlCommand(query, sqlcon);
da = new SqlDataAdapter(sqlcmd);
if (dt.Rows.Count > 0)
ReportDocument RptDoc = new ReportDocument();


CrystalReportViewer1.ReportSource = RptDoc;
catch (Exception ex)

Source Code Detail:
Here with I have attached source code with Database and its details. Download it and try to learn display images in crystal report.
Front End : ASP.NET
Code Behind : C#

I hope my two articles is help to beginners for understand Concept of Image store and Retrieve/display process.


  • ImageDisplay_crystalReport (42907-311033-DisplayPicture.rar)
  • Comments

    No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: