[英]Vb.NET 2012 and Crystal Report support packs 12 - always ask for database login
need your help about this one.. i'm writing code from vb.net 2013 and Crystal Report SP12 from here http://scn.sap.com/docs/DOC-7824 . 需要您的帮助。.我正在从vb.net 2013和Crystal Report SP12编写代码, 网址为http://scn.sap.com/docs/DOC-7824 。 i'm trying to use record selection and it was running well, but when i add some code to passing a parameter to the Crystal Report, it start to make me dizzy. 我试图使用记录选择,并且运行良好,但是当我添加一些代码以将参数传递给Crystal Report时,它开始让我感到头晕。 here are the code for passing the parameter using Parameter fields in Crystal 这是使用Crystal中的Parameter字段传递参数的代码
Report1.SetParameterValue("Prm_Priority", PassingVar) Report1.SetParameterValue(“ Prm_Priority”,PassingVar)
And Here are my full code: 这是我的完整代码:
Imports CrystalDecisions.CrystalReports.Engine 导入CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared 导入CrystalDecisions.Shared
and for procedure 和程序
Dim A As CrystalDecisions.CrystalReports.Engine.Table Dim B As CrystalDecisions.Shared.TableLogOnInfo Report1 = New ReportDocument() Report1.Load("C:\\folders\\Report1_.rpt") For Each A In Report1.Database.Tables B = A.LogOnInfo With B.ConnectionInfo .ServerName = "" .UserID = "someuserid" .Password = "somepassword" .DatabaseName = "someDb" End With A.ApplyLogOnInfo(B) Next A Report1.SetParameterValue("Prm_Priority", Textbox1.text) Report1.RecordSelectionFormula = "{DB.Table} =" & Trim(Textbox2.text)> Me.CrystalReportViewer1.ReportSource = Report1
I have read some reference but it seems does not make any deference, the password still came up, here are my reference link: Crystal Report always asks for database login 我已经阅读了一些参考资料,但似乎没有做任何贡献,仍然输入了密码,这是我的参考资料链接: Crystal Report始终要求数据库登录
http://www.codeproject.com/Questions/73898/Crystal-report-popping-up-login-credential-always http://www.codeproject.com/Questions/73898/Crystal-report-popping-up-login-credential-always
could you guys help me out, am i missing some thing here..Thank you in advance guys.. 你们可以帮我吗,我在这里错过了什么吗。.预先谢谢你们..
I know you linked the other question, but instead of doing what you're doing, have you tried to simply do this: 我知道您链接了另一个问题,但是您没有做您正在做的事情,而是尝试简单地做到这一点:
crDocument.SetDatabaseLogon("user", "password", "server", "database")
crptViewer.ReportSource = crDocument
I only use a For Each Table in Tables
like you're doing when I have multiple database connections on a single report. 当我在一个报表上有多个数据库连接时,只能像For Each Table in Tables
那样使用For Each Table in Tables
。
You may also need to loop through additional sub reports if you have them and do the same thing (you maybe getting the database login prompt because something additional you're not changing is causing it). 如果您有其他子报表并执行相同的操作,则可能还需要循环浏览其他子报表(您可能会收到数据库登录提示,因为您未更改的其他内容会引起它)。 Here is a sub procedure I use that's always worked for me. 这是我一直使用的子过程。 Note in this that I've pulled it out of a class so the "Me.ServerName" is coming from a property, you can add that in like you do above. 请注意,我已将其从类中拉出,因此“ Me.ServerName”来自属性,您可以像上面所做的那样添加它。
Also, Crystal Reports through .Net is very finicky about when things are set. 此外,通过.Net的Crystal Reports对于设置的时间非常挑剔。 You have to set sub report connections before table connections. 您必须在连接表之前设置子报表连接。
''' <summary>
''' Applies the contents of the ConnectionString property to the report (if it's been set).
''' </summary>
''' <remarks></remarks>
Private Sub ApplyNewServer(ByVal report As ReportDocument)
If Me.ServerName = "" Then
Exit Sub
End If
For Each subReport As ReportDocument In report.Subreports
For Each crTable As Table In subReport.Database.Tables
Dim loi As TableLogOnInfo = crTable.LogOnInfo
loi.ConnectionInfo.ServerName = Me.ServerName
If Me.UseTrustedConnection = True Then
loi.ConnectionInfo.IntegratedSecurity = True
Else
loi.ConnectionInfo.UserID = Me.Username
loi.ConnectionInfo.Password = Me.Password
End If
crTable.ApplyLogOnInfo(loi)
Next
Next
'Loop through each table in the report and apply the new login information (in our case, a DSN)
For Each crTable As Table In report.Database.Tables
Dim loi As TableLogOnInfo = crTable.LogOnInfo
loi.ConnectionInfo.ServerName = Me.ServerName
If Me.UseTrustedConnection = True Then
loi.ConnectionInfo.IntegratedSecurity = True
Else
loi.ConnectionInfo.UserID = Me.Username
loi.ConnectionInfo.Password = Me.Password
End If
crTable.ApplyLogOnInfo(loi)
'If your DatabaseName is changing at runtime, specify the table location.
'crTable.Location = ci.DatabaseName & ".dbo." & crTable.Location.Substring(crTable.Location.LastIndexOf(".") + 1)
Next
End Sub
http://www.blakepell.com/2010-09-17-crystal-reports-changing-the-database-connection-from-net-subreport-links-and-the-case-of-the-missing-parameter-values http://www.blakepell.com/2010-09-17-crystal-reports-changing-the-database-connection-from-net-subreport-links-and-the-case-of-the-missing-parameter-值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.