How to dynamically change crystal report database connection(如何动态更改水晶报表数据库连接)
问题描述
我是水晶报告的新手.我尝试使用报表向导 Visual Studio 2012 在我的 win form c# 应用程序中实现水晶报表,所以不知道反手会发生什么.一切在我的计算机上运行良好,但是当我尝试在另一台计算机上安装它时,连接字符串发生变化并出现错误.
I am new with crystal reports. I tried to to implement the crystal report in my win form c# application using report wizard visual studio 2012, so don't know what happen's in backhand for this. Everything works good on my computer but when i tried install this on another computer connection string changes and gives error.
我尝试了许多链接,例如 动态连接字符串更改但由于我正在使用报告向导进行设置,所以不知道在哪里使用它.
I tried many links like Dynamic Connection string Change but as i am using report wizard for setup so don't know where to use this.
我还尝试了报告向导中连接字符串的所有选项,但没有找到在运行时更改连接字符串的任何内容.
I also tried all options in report wizard for connection string but didn't find anything that change connection string at run time.
是否有任何选项可以让我在运行时从应用配置附加连接字符串
.
Is there any options by which i can attach connection String from app config at run time
.
推荐答案
试试这样的:
strServer= ConfigurationManager.AppSettings["ServerName"].ToString();
strDatabase= ConfigurationManager.AppSettings["DataBaseName"].ToString();
strUserID= ConfigurationManager.AppSettings["UserId"].ToString();
strPwd= ConfigurationManager.AppSettings["Password"].ToString();
report.DataSourceConnections[0].SetConnection(strServer, strDatabase, strUserID, strPwd);
这篇关于如何动态更改水晶报表数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何动态更改水晶报表数据库连接


- C# 通过连接字符串检索正确的 DbConnection 对象 2022-01-01
- 在 C# 中异步处理项目队列 2022-01-01
- 是否可以在 .Net 3.5 中进行通用控件? 2022-01-01
- 为什么 C# 中的堆栈大小正好是 1 MB? 2022-01-01
- Azure Active Directory 与 MVC,客户端和资源标识同一 2022-01-01
- 在 LINQ to SQL 中使用 contains() 2022-01-01
- 使用 rss + c# 2022-01-01
- 带问号的 nvarchar 列结果 2022-01-01
- CanBeNull和ReSharper-将其用于异步任务? 2022-01-01
- Windows 喜欢在 LINUX 中使用 MONO 进行服务开发? 2022-01-01