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
Loading

Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 17, 2015, 10:03 PM EST
Remove foreach, Instead of that :
DataRow dr = dt.Rows[0];
dr["Image"] = imgbyte;
This will set image in first row only..
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 2:15 AM EST
i make as thread above
but it give me error message
access is denied to path
i can open the path delete edit do every thing in this path
why give me error message
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 2:27 AM EST
is it your PC or different?
If it is diff. PC, try to open it from RUN. Is there any credential to access?
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 2:37 AM EST
but i dont know why problem in my code
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 2:38 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 2:38 AM EST
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 2:41 AM EST
Go to Personal Picture folder property and Uncheck Read Only in attributes.
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 2:42 AM EST
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 2:44 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 2:53 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 3:19 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 3:22 AM EST
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 3:23 AM EST
Give your code from foreach..
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 3:27 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 3:36 AM EST
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 3:42 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 3:46 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 4:01 AM EST
ahmed saRank #8,218 · 226 reputationPosted Feb 18, 2015, 4:22 AM EST
Vikram AgrawalRank #4,713 · 329 reputationPosted Mar 15, 2015, 11:20 PM EDT
Hi ahmed sa,
you can use one default pic for all employees. Display this default pic for all those employees who don't have any pic. If employee have any associated image then display that image.
Thanks.
Piyush PansuriyaRank #454 · 5.5K reputationPosted Feb 18, 2015, 3:47 AM EST
for (int i; i <= dt.Rows.count; i++)
{
DataRow dr = dt.Rows[i];
FileStream fs=null;
fs = new FileStream("\\\\192.168.1.105\\Personal Pictures\\" +dr[i]+ ".jpg", FileMode.Open);
BinaryReader br = new BinaryReader(fs);
byte[] imgbyte = new byte[fs.Length + 1];
imgbyte = br.ReadBytes(Convert.ToInt32((fs.Length)));
dr["Image"] = imgbyte;
fs.Dispose();
}
Make sure that all files have to exist in folder which are in DataTable.