Crystal Report Hosting BLOG

All about Crystal Report 2010 Hosting and Crystal Report 2008 Hosting articles

Crystal Report Hosting :: Dynamic Images at runtime in Crystal Report XI using ASP.Net 2.0

clock June 9, 2011 17:46 by author Administrator

This article helps to display dynamic Images in crystal report Using ASP.Net 2.0.

We can use two methods to dynamically change the picture in the crystal report either the Image stored in the database as a BLOB and as a picture available in the local path.

Method I: Using recordset

1. Add a recordset and add a table in that. Add a column of System.Byte[] (Only System.Byte is available in the data type of data Table, Manually add the System.Byte[] in that. System.Byte not allowed for images).Then use the below code

2. Design the report with that dataset. You can add this System.Byte[] column as part of your main data table which have the all data or add a separate data table with a System.Byte[] and a key column that link to the main data table.

3. Add the below code

private ds_Images Images1;
rptTest crReportDocument = new rptTest(); // rptTest is your crystal report name

protected void btnShowReport_Click(object sender, EventArgs e)
ImageTable(); crReportDocument.Database.Tables["tblImages"].SetDataSource(Images1.Tables[0].DataSet);
string ExportPathFinal;
ExportPathFinal = ExportPath + "\\" + "TEMP" + "\\";
if (Directory.Exists(ExportPathFinal) == false) Directory.CreateDirectory(ExportPathFinal);

//Export Crystal Report to PDF
ExportOptions crExportOptions = new ExportOptions();
DiskFileDestinationOptions crDiskFileDestinationOptions = new DiskFileDestinationOptions();
crExportOptions = crReportDocument.ExportOptions;
crDiskFileDestinationOptions.DiskFileName = ExportPathFinal + "MyreportTest.pdf";

//Set the required report ExportOptions properties
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; // Or any other Format
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;

string ExportPathFinal1 = ExportPath1 + "\\" + "TEMP" + "\\";
string pathToPDFfile = ExportPathFinal1 + "MyreportTest.pdf";
Response.Redirect(pathToPDFfile, true);
//Close and dispose of report

private void ImageTable()
ds_Images Images1 = new ds_Images();
string fileName = @"\\img\a.JPG";
fileName = Server.MapPath(fileName.Trim());
DataRow row;
Images1.Tables[0].TableName = "tblImages";
Images1.Tables[0].Columns.Add("img", System.Type.GetType("System.Byte[]"));
row = Images1.Tables[0].NewRow();
FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
row[0] = br.ReadBytes(Convert.ToInt32(br.BaseStream.Length));
row[1] = 1;
br = null;
fs = null;

Method II: Using Picture Object of Crystal Report

Using the Dynamic Graphic Location of picture OLE object of crystal report, we can change picture dynamically at run-time.

1. Create a parameter field in the report with string data type.
2 In the report Add a picture OLE object. inside report right click->Insert->OLE object- >select Bitmap Image
3 Right click the OLE picture object and select Format Object- >select Picture tab ->Graphic location -> inside it drag the parameter field.

in the front end just pass the Image URL to the report

ParameterDiscreteValue crParameterimgLocation;
string img_url = @"\\images/newImages/nevadadot.JPG";
img_url = Server.MapPath(img_url);
crParameterField = crParameterFields["imgLocation"];
crParameterValues = crParameterField.CurrentValues;
this.crParameterimgLocation = new ParameterDiscreteValue();
this.crParameterimgLocation.Value = img_url;

//Add current value for the parameter field

Note: while passing the Image URL do not put put single quotes.

We can use either method to display the Images in the report dynamically.

In Crystal Reports XI, the 'Dynamic Image Location' feature does not work with images in GIF format. Why does this behavior occur and how can you resolve it?" This drawback matches to the recordset method too.

"To debug the issue

This behavior occurs because Crystal Reports XI does not fully support the GIF file format. To resolve this behavior, use a supported image format when working with the 'Dynamic Image Location' feature. Supported image formats are Joint Photographic Experts (JPG), bitmap (BMP), Tagged Image File Format (TIF) and Portable Network Graphics (PNG)."

Any comments appreciated

Currently rated 1.5 by 4 people

  • Currently 1.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Crystal Report v13 Hosting with

clock May 11, 2011 20:28 by author Administrator, a premier provider in advanced Windows and ASP.NET hosting service, proudly announces the availability of the latest Crystal Report v13 hosting on our newest Windows Server 2008 Hosting Platform.

You can start hosting your Crystal Report v13 project on our environment from as just low as $4.49/month only. For more details about this product, please visit our product page at     

Crystal Reports has been a part of Visual Basic since 1993, and a part of Visual Studio since its first release in 2002. Crystal Reports has been a very successful component of these products. With the release of Visual Studio 2010, SAP and Microsoft have mutually decided to change how we deliver this important component to the .NET developer community going forward," said Tom Heinrich, General Manager of ASPHostCentral.

Crystal Reports for Visual Studio 2010 will contain many new features compared to Crystal Reports Basic for Visual Studio 2008
," said Senior Support Specialist, Ryan Dalgish.

The demonstrations can be found at

For more details, please visit:  

ASPHostCentral is a premier web hosting company where you will find low cost and
reliable web hosting services. Whether you're an enterprise level business or a small business entity or someone who just wants to host his own personal website - we have a suitable web hosting solution for you.
For more information, visit

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Crystal Report Hosting

ASPHostCentral is a premier web hosting company where you will find low cost and reliable web hosting. We have supported the latest Crystal Report 2010 (v13 and v14) hosting. We have also supported the latest ASP.NET 4.5 hosting and ASP.NET MVC 4 hosting. We have supported the latest SQL Server 2012 Hosting and Windows Server 2012 Hosting too!


Sign in