By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,131 Members | 1,560 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,131 IT Pros & Developers. It's quick & easy.

Loading a image in crystal report XI

P: n/a
Hi ,
I am working in c# with crystal report XI.
I read an example about dynamic image location ..

1) In that we have a xml xchema file with two fields n amed
country--datatype is string, img--datatype is base64Binary. using this as the
datasource,i have designed the crytal report. And a parameter is set asking
for the name.

2) I have designed teh form by adding a crystal report viewer and
now the coding part is as follows
// Prcocedure: AddImageRow
// reads an image file and adds this image to a dataset table
// [in] tbl DataTable
// country name of a country
// filename name of an image file
void AddImageRow(DataTable tbl, string name, string filename)
FileStream fs = new FileStream(filename, FileMode.Open);
// create a file stream
BinaryReader br = new BinaryReader(fs);
// create binary reader
DataRow row;
// create a new datarow
row = tbl.NewRow();
// set country field and image field
row[0] = name;
row = br.ReadBytes((int)br.BaseStream.Length);
// add this row to the table
// clean up
br = null;
fs = null;
// Function: CreateData
// Creates a dataset that has 1 table with two fields: Country (string), and
img (blob/byte[])
// Adds four records to this table
DataSet CreateData()
DataSet data = new DataSet();
// add a table 'Images' to the dataset
// add two fields
data.Tables[0].Columns.Add("img", System.Type.GetType("System.Byte[]"));
// add rows
AddImageRow(data.Tables[0], "argentina", Directory.GetCurrentDirectory()
+ "\\argentina.jpg");
AddImageRow(data.Tables[0], "canada", Directory.GetCurrentDirectory() +

return (data);
// Procedure: CreateReport
// Creates a report and passes the dataset

void CreateReport()
// create a report
CrystalReport1 cr = new CrystalReport1();
// pass a reportdocument to the viewer
crystalReportViewer1.ReportSource = cr;

public Form1()
// Required for Windows Form Designer support
// TODO: Add any constructor code after InitializeComponent call

This is the coding,when the program is run the image which is
existing in the directory (say argentina.jpg and canada.jpg). it will ask for
country if we type canada..then canada.jpg wil be displyed in the
This is wht the program does..
No I have to modify such that .. I have to add a buttn on the form say when the load button is clicked, we should be able to load any image
from the disk(any location) and that image should be displayed in the crystal
report..How to do this..
please if any one change the coding part above and sent it .
Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.