在C#Windows应用程序中加载Crystal Report [英] Loading Crystal Report in C# Windows Application

查看:58
本文介绍了在C#Windows应用程序中加载Crystal Report的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在C#Windows应用程序中创建CrystalReport时,我将数据源加载为

Hi,
When i creating CrystalReport in C# Windows application i load the data source as

ReportDocument stu = new ReportDocument();
stu.Load("samplereport.rpt");
DataSet ds = objstudent.SelectStudent_report();
stu.SetDataSource(ds.Tables[0]);
crystalReportViewer1.ReportSource = stu;
crystalReportViewer1.Visible = true;
crystalReportViewer1.Enabled = true;


在这里它给出了一个错误,因为加载报告失败." ..
但是我将路径指定为


here it give an error as "Load report failed."..
but wen i specifying path as

stu.Load("G:\\ISR\\ISR project\\phase 1\\isr\\isr\\samplereport.rpt");


它会正常工作.

如何在不指定报告整个路径的情况下加载数据源.



谢谢你...


it will work properly.

how we can load the datasourse without specifing the entire path of the report.



Thank u...

推荐答案

作为我的知识,您应该提供加载报告的完整路径
这里没有任何指定路径的快捷方法.
As my knowladge, you should provide entire path to load report
here is no any shortcut method to specify path.


位置(路径)必须通过,
而不是静态传递它,而应动态检测路径.
Location (path) must be pass,
and instead of passing it statically you should detect path dynamically.
string rptpath="G:\\ISR\\ISR project\\phase 1\\isr\\isr\\samplereport.rpt";


例如


e.g.

path = System.IO.Path.GetDirectoryName(
      System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase );
string rptpath=path + "\\samplereport.rpt";


祝您编码愉快!
:)


Happy Coding!
:)


这篇关于在C#Windows应用程序中加载Crystal Report的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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