问题描述
我是水晶报告的新手.我尝试使用报表向导 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);
这篇关于如何动态更改水晶报表数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!