本文介绍了在运行时更改Crystal数据库连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我使用visual studio 2013,Crystal版本13.0.12,SQL server 2014. i有3个sql数据库。每个在表格和视图等方面都具有完全相同的结构。 DB1 DB2 DB3 我创建了一个通过OLEDB连接到DB1的报告。 在运行时,我希望报告指向DB2 OR DB3,具体取决于用户配置文件或访问权限,即用户只能查看DB1或DB2。每个数据库都有公司敏感数据,因此用户绝不能看到任何其他数据库数据。 每个数据库都有自己的sql用户和密码用于登录/读取目的。 i尝试了以下... Dim _rd As ReportDocument = New ReportDocument() Dim reportPath As String = Server.MapPath(Request(Report)) _rd.Load(reportPath) _rd.DataSourceConnections.Clear() Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo() Dim myTables As Tables = _rd.Database.Tables For Each myTable As CrystalDecisions.CrystalReports.Engine.Table in myTables Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo myConnectionInfo.ServerName =MYSERVER myConnectionInfo.DatabaseName =DB1 myConnectionInfo.UserID =USERDB1 myConnectionInfo.Password =PASSWORDDB1 myTableLogonInfo.ConnectionInfo = myConnectionInfo myTable.ApplyLog OnInfo(myTableLogonInfo)下一个 CrystalReportViewer1.ReportSource = _rd 问题是每当我运行报告时它总是提示数据库登录??? 服务器:正确。 用户:不正确 密码:不正确 数据库:空白 i甚至尝试设置属性EnableDatabasePrompt= False但似乎仍在寻找... 如何解决??? 提前感谢 Anoop 解决方案 Hi,Im using visual studio 2013, Crystal version 13.0.12, SQL server 2014.i have a 3 sql databases. each has the exact same structure in terms of tables and views etc.DB1DB2DB3I have created a report that connects via OLEDB to DB1.At runtime, i want the report to point to either DB2 OR DB3 depending on the user profile or access i.e. the user can only view either DB1 or DB2. Each DB has company sensitive data so in no way must the user see any other DB data.Each DB has its own sql user and password for login/read purposes.i have tried the following...Dim _rd As ReportDocument = New ReportDocument()Dim reportPath As String = Server.MapPath(Request("Report"))_rd.Load(reportPath)_rd.DataSourceConnections.Clear()Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()Dim myTables As Tables = _rd.Database.TablesFor Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo myConnectionInfo.ServerName = "MYSERVER" myConnectionInfo.DatabaseName = "DB1" myConnectionInfo.UserID = "USERDB1" myConnectionInfo.Password = "PASSWORDDB1" myTableLogonInfo.ConnectionInfo = myConnectionInfo myTable.ApplyLogOnInfo(myTableLogonInfo)Next CrystalReportViewer1.ReportSource = _rdthe problem is that whenever i run the report it always prompts for database login???server: correct.user: incorrectpassword: incorrectDatabase: blanki even tried to set the property "EnableDatabasePrompt" =False but it seems to be still looking...how do i resolve???thanks in advanceAnoop 解决方案 这篇关于在运行时更改Crystal数据库连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-26 05:36