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);
这篇关于如何动态更改水晶报表数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何动态更改水晶报表数据库连接
基础教程推荐
- 全局 ASAX - 获取服务器名称 2022-01-01
- 如何动态获取文本框中datagridview列的总和 2022-01-01
- 首先创建代码,多对多,关联表中的附加字段 2022-01-01
- 错误“此流不支持搜索操作"在 C# 中 2022-01-01
- 从 VS 2017 .NET Core 项目的发布目录中排除文件 2022-01-01
- JSON.NET 中基于属性的类型解析 2022-01-01
- 经典 Asp 中的 ResolveUrl/Url.Content 等效项 2022-01-01
- 将事件 TextChanged 分配给表单中的所有文本框 2022-01-01
- 在 VS2010 中的 Post Build 事件中将 bin 文件复制到物 2022-01-01
- 是否可以在 asp classic 和 asp.net 之间共享会话状态 2022-01-01
