如何在C#窗口应用程序中显示Crystal Report中的照片 [英] How to show Photos in Crystal Report in C# Window Application
本文介绍了如何在C#窗口应用程序中显示Crystal Report中的照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我在表格中添加新员工时。然后我想在c#window应用程序中显示水晶报告中员工的照片..我想在水晶报告中显示特定员工代码的照片。这该怎么做 ? PLZ帮助..提前感谢...
解决方案
这有点粗略,但我记得几年前做过这个。
我会尝试起草一系列步骤,但这不是100%准确。我只能在星期一从我的工作桌面获得工作解决方案:]
如果我没记错的话,我就是这样做的;
(1)水晶报告(版本11),允许您使用程序构建报告,因此从以下程序结果集创建水晶报告,
创建表tbl_employees(
id int,name nvarchar(100),id_path nvarchar(100),id_file varbinay(1024)
)
select * from tbl_employees
(2)所以在.cs代码上检索此结果集,循环结果集,并获取id_path,并将该文件放入byte []数组,并将其分配给id_file字段。像这样的东西,
foreach(Datarow dr in tbl.Rows)
{
string path = Server .Mappath(Convert.ToString(dr [id_path]));
byte [] buff = File.ReadAllBytes(path);
dr [id_file] = buff;
buff = null;
}
(3)最后,将数据表绑定到cystal报告的.datasource。
我只是动态地输入这个解决方案,它是也不是优雅的:]
Goodluck。希望这有帮助。
你也可以通过以下谷歌搜索的想法;
http://stackoverflow.com/ question / 7706662 / add-image-to-crystal-at-runtime
http://stackoverflow.com/questions/128239/dynamically-change-an-image-in-a-crystal -report-在运行时
when i add a new employee in table. then i want to show photo of the employee in crystal report in c# window application.. i want display the photo of particular employee code in crystal report. how to do this ? plz help .. thanks in advance ...
解决方案
hi, this is a bit sketchy, but i remember having done this a few years back.
i'll try to draft a series of steps, but it's not 100% accurate. i'd only be able to get the working solution from my work desktop on monday :]
if i recall correctly, this is how i did it;
(1) crystal reports (ver.11), can allow you to build a report using a procedure, so create a crystal report from the following procedure result set,
create table tbl_employees (
id int, name nvarchar(100), id_path nvarchar(100), id_file varbinay(1024)
)
select * from tbl_employees
(2) so on the .cs code that retrieves this result set, loop on the result set, and get the id_path, and get that file into a byte[] array, and assign it to the id_file field,. something like this,
foreach (Datarow dr in tbl.Rows)
{
string path = Server.Mappath(Convert.ToString(dr["id_path"]));
byte[] buff = File.ReadAllBytes(path);
dr["id_file"] = buff;
buff = null;
}
(3) finally, bind the datatable to the cystal report's .datasource.
I'm only typing this solution on the fly, and it's not an elegant one either :]
Goodluck. hope this helped.
you can also go through the following googled ideas;
http://stackoverflow.com/questions/7706662/add-image-to-crystal-report-at-runtime
http://stackoverflow.com/questions/128239/dynamically-change-an-image-in-a-crystal-report-at-runtime
这篇关于如何在C#窗口应用程序中显示Crystal Report中的照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文