C#中的动态加载.rpt [英] Dynamic load .rpt in C#

查看:355
本文介绍了C#中的动态加载.rpt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





Hi,

try
{
string spath = AppDomain.CurrentDomain.BaseDirectory;spath += "myReportFileName.rpt";
ReportDocument cryRpt = new ReportDocument();
cryRpt.Load(spath);
cryRpt.DataSourceConnections[0].SetConnection("Server Name", "DB Name", true);
cryRpt.DataSourceConnections[0].IntegratedSecurity = true;
cryRpt.SetParameterValue("Field Name", "Value");
cryRpt.RecordSelectionFormula = "Correct Formula";
crystalReportViewer1.ReportSource = cryRpt;crystalReportViewer1.Refresh();
}
catch (System.Exception ex)
{
MessageBox.Show("Error: " + ex.Message);
}



在我的系统中,此代码没问题。但在其他系统中,它有错误。我在所有其他系统中正确安装了水晶报告。



此代码执行时出错:

crystaldecisions.crystalreports.engine.reportdocument'threw一个例外



然后我在客户端系统中执行** CRRuntime_32bit_13_0_3.msi **。那个错误解决了**但**其他问题:

运行代码后,显示数据库登录对话框,我没有自动连接到数据库,也没有查看报告档案!!!



请帮帮我,我该怎么办?



什么我试过了:



要在C#代码中查看.rpt文件,请动态设置服务器和数据库


In my system, this code is ok. But in other system, It has error. I installed in all other systems crystal report correctly.

This code was executing with error:
crystaldecisions.crystalreports.engine.reportdocument' threw an exception

Then i executed **CRRuntime_32bit_13_0_3.msi** in client system. That error solved **But** other problem:
After to run code, the "Database Login" dialog is showing, and I don't connect to database automatically, and don't view the report file!!!

please help me, what have to i do?

What I have tried:

To view .rpt file in C# code, dynamically set server and database

推荐答案

我解决了我的问题。 :)

当我创建项目时,我的系统上安装了crystalReport版本10。因此我从Toolbox Item中选择了crystalReportViewer版本10。

我卸载了水晶报告版本10并安装了版本11.在下一步中,我从visual studio的工具箱中删除了crystalReportViewer然后又选择了crystalReportViewer版本 11来自Toolbox Item。



现在我的项目和创建的exe文件,在所有具有晶体报告版本10的systam中正确执行。



谢谢!
I solved my problem. :)
when I was creating the project , the crystalReport version 10 had been installed on my system. therefor I choosed "crystalReportViewer version 10" from Toolbox Item.
I uninstalled version 10 of crystal report and installed version 11. In next step, I deleted crystalReportViewer from toolbox of visual studio then again choosed "crystalReportViewer version 11" from Toolbox Item.

now my project and created exe file, executes correctly in all systam that has crystall report vesion 10 later.

thank you!


这篇关于C#中的动态加载.rpt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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