水晶报告源路径动态 [英] crystal report source path dynamically

查看:59
本文介绍了水晶报告源路径动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,这是我的第一个问题,这是个好问题,,,,

i有包含水晶报告的c#应用程序,一切正常,除非我更改文件位置,否则会出错loading field

 ReportDocument rpt =  new  ReportDocument(); 
rpt.Load( C:\\Users\\mypce \\Desktop \\ file \\CrystalReport1.rpt);
crystalReportViewer1.ReportSource = rpt;



所以我想要的是动态制作路径,或者我可以将此路径放在配置文件中,我可以随时更改, ,,

解决方案

您可以在配置文件中定义报告路径,如下所述:

http://stackoverflow.com/questions/13152765/declare-a-string-in-web-config-file [ ^ ]

如下面链接所述,使用以下代码:

 <   appsettings  >  
< add key = dir < span class =code-attribute> value = YourReportPathHereInProperFormat / >
< / appsettings >



  string  dir = ConfigurationManager.AppSettings [  dir]。ToString(); 



有关AppSettings的更多信息,请参阅以下文章:

Web.config文件 - ASP.NET [ ^ ]

谢谢。


感谢您的重播,我在申请中工作是为了网络吗?

然而我知道这是正确的答案,但我没有正确使用

i像这样使用它

  //   ReportDocument rpt = new ReportDocument();  
string crystalrp = ConfigurationManager.AppSettings [ cry]。ToString();
crystalReportViewer1.ReportSource = crystalrp;



并没有效果抱歉,但你可以帮我解决这个问题吗,


  string  st = ConfigurationManager.AppSettings [  crystalrp< /跨度>]的ToString(); 
ReportDocument rpt = new ReportDocument();
rpt.Load(st);
crystalReportViewer1.ReportSource = rpt;



非常感谢你帮助,,,,


hello everyone ,, this is my first question here be good question,,,,
i have c# application that contain crystal reports , everything work fine except when i change file location and it will give error "loading field"

ReportDocument rpt = new ReportDocument();
            rpt.Load("C:\\Users\\mypce\\Desktop\\file \\CrystalReport1.rpt");
            crystalReportViewer1.ReportSource = rpt;


so what i want is make path dynamically , or can i put this path in config file that i can change any time ,,,

解决方案

You can simply define path of report in config file as discussed here:
http://stackoverflow.com/questions/13152765/declare-a-string-in-web-config-file[^]
As described at below link, use following code:

<appsettings>
    <add key="dir" value="YourReportPathHereInProperFormat" />
  </appsettings>


string dir = ConfigurationManager.AppSettings["dir"].ToString();


For more look into "AppSettings" at below article:
Web.config File - ASP.NET[^]
Thanks.


thanks for your replay, i do work in application is this for web?
however i know this is right answer but i didn't use it correctly
i used it like this

//ReportDocument rpt = new ReportDocument();
           string crystalrp = ConfigurationManager.AppSettings["cry"].ToString();
           crystalReportViewer1.ReportSource = crystalrp; 


and didn't work sorry but can you help me with this plz,,,


string st = ConfigurationManager.AppSettings["crystalrp"].ToString();
         ReportDocument rpt = new ReportDocument();
         rpt.Load(st);
            crystalReportViewer1.ReportSource = rpt ;


thank you so much for helps ,,,,


这篇关于水晶报告源路径动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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