如何动态更改水晶报表数据库连接

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);

这篇关于如何动态更改水晶报表数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)