wpf 通过图像路径在数据库中的 RDLC 报告上显示图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16888805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 08:54:25  来源:igfitidea点击:

Show image on RDLC report from database by image path

c#wpfsql-server-2008reporting-servicesrdlc

提问by Gauri K.

The image path is stored in the SQL Server 2008 database. On my RDLC report, I have a image field. I have set this field to get the image path from the database column in the database. I also have set in the report viewer the "EnableExternalImages" property to true. I don't know what I am missing, but the only "image" my report shows is the red mark. What am I missing?

图像路径存储在 SQL Server 2008 数据库中。在我的 RDLC 报告中,我有一个图像字段。我已设置此字段以从数据库中的数据库列获取图像路径。我还在报告查看器中将“EnableExternalImages”属性设置为 true。我不知道我错过了什么,但我的报告显示的唯一“图像”是红色标记。我错过了什么?

采纳答案by Gauri K.

The problem was that I did set the image source property of the image control on the report to "database", which is incorrect. Because the image is not saved in the database, but only the path to it. So I changed it to "External" and walah! It works like a charm. Thank you all for your help.

问题是我确实把报表上图片控件的图片源属性设置为“database”,这是不正确的。因为图像没有保存在数据库中,而只有它的路径。所以我把它改成了“外部”和 walah!它就像一个魅力。谢谢大家的帮助。

回答by petchirajan

For display the external image in RDLC report,

为了在 RDLC 报告中显示外部图像,

  • You have to set EnableExternalImages to true.

  • The file path you are using should be absolute path. The path you are using should be in the form of "file:///C:/RDLCTest/TestImage.png".

  • Also, you have to set the MIME type for the image control. Each file type has its own MIME type. Refer http://webdesign.about.com/od/multimedia/a/mime-types-by-file-extension.htmfor list of MIME types based on file extension.

  • 您必须将 EnableExternalImages 设置为 true。

  • 您使用的文件路径应该是绝对路径。您使用的路径应该是“file:///C:/RDLCTest/TestImage.png”的形式。

  • 此外,您必须为图像控件设置 MIME 类型。每种文件类型都有自己的 MIME 类型。有关基于文件扩展名的 MIME 类型列表,请参阅http://webdesign.about.com/od/multimedia/a/mime-types-by-file-extension.htm

回答by solanki dev

reportViewer.LocalReport.ReportPath = @"Report Path";                                    
reportViewer.LocalReport.EnableExternalImages = true;                                
ReportParameter parameter = new ReportParameter("ImagePath", imagePath);              
ReportParameter[] param = new ReportParameter[1];                                      
param[0] = parameter;                                                                 
reportViewer.LocalReport.SetParameters(param);                                        
reportViewer.RefreshReport();  

http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx

http://www.aspsnippets.com/Articles/Dynamically-add-and-display-external-Image-in-RDLC-Report-from-code-behind-in-ASPNet.aspx