在Crystal报告的下一行中重复的第一张图片报告了什么错误的代码 [英] First picture repeating in next rows in crystal reports problem what wrong code

查看:97
本文介绍了在Crystal报告的下一行中重复的第一张图片报告了什么错误的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我尝试在水晶报表中显示更多图片,但我的水晶报表版本不允许我制作链接图片,这意味着
图片选项卡在Crystal报表中没有图形位置公式
现在我要如何解决这个问题
我尝试通过代码来实现以下代码中的工作,但
下一行重复的第一张图片
我的代码如下(仅显示一张图片)

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();


现在,我必须进行哪些修改才能防止第一张图片在下一条记录中重复
水晶报表显示ID AND Image


Now what modification i must do to prevent first picture from repeating in next records
Crystal report show ID AND Image

推荐答案

foreach (DataRow dr in dt.Rows)
{
    dr["Image"] = imgbyte;
}


实际上,在这里您将同一图像分配给列"Image"上的所有行.这就是为什么它会重复.您应该根据需要为每行分配不同的图像或类似的图像.


Actually, here you are assigning the same image to all the Rows on Column "Image". That''s why it is repeating. You should assign different images to every row or something like that according to your requirements.


这篇关于在Crystal报告的下一行中重复的第一张图片报告了什么错误的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆