-
February 18th, 2015, 02:54 AM
#1
First picture repeating in next rows in crystal reports problem what wrong code
Hi guys i try to show more pictures in crystal reports but my version of crystal report not allow to me to make link pictures meaning
picture tab not have graphic location formula in crystal report
Now what i do to solve this problem
i try from code to do that it working from code below but
first picture repeating in next rows
my code as following (only show one picture)
DataTable dt = new DataTable();
string connString = "data source=192.168.1.105; initial catalog=hrdata;uid=sa; password=1234";
using (SqlConnection con = new SqlConnection(connString))
{
con.Open();
SqlCommand cmd = new SqlCommand("ViewEmployeeNoR", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
da.Fill(dt);
}
FileStream fs=null;
fs = new FileStream("\\\\192.168.1.105\\Personal Pictures\\" + ".jpg", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] imgbyte = new byte[fs.Length + 1];
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
foreach (DataRow dr in dt.Rows)
{
dr["Image"] = imgbyte;
}
ReportDocument objRpt = new Reports.CrystalReportData2();
objRpt.SetDataSource(dt);
crystalReportViewer1.ReportSource = objRpt;
crystalReportViewer1.Refresh();
Now what modification i must do to prevent first picture from repeating in next records
Crystal report show ID AND Image
-
February 19th, 2015, 09:49 AM
#2
Re: First picture repeating in next rows in crystal reports problem what wrong code
If you want only one image to appear, this should work.
Code:
foreach (DataRow dr in dt.Rows)
{
dr["Image"] = imgbyte;
imgbype = null;
}
If you want a new picture for each row, something like this should work.
Code:
FileStream fs=null;
BinaryReader br = null;
byte[] imgbyte = null;
foreach (DataRow dr in dt.Rows)
{
// change path to each specific image
fs = new FileStream("\\\\192.168.1.105\\Personal Pictures\\" + ".jpg", FileMode.Open);
br = new BinaryReader(fs);
imgbyte = new byte[fs.Length + 1];
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
dr["Image"] = imgbyte;
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|