水晶报表问题-登录提示 [英] Crystal reports issue - LogOn prompt
问题描述
我有一个Web应用程序,该应用程序使用Crystal Report 12.0显示报告.
我面临的问题是,当我生成一个记录高达20,000的报告时,它是成功的,但是对于高于此的记录,它给我的错误如下:
您请求的报告需要更多信息.
-------------------------------------------------- ------------------------------
服务器名称:
数据库名称:
用户名:
密码:
使用集成安全性
-------------------------------------------------- --------------------------------
谷歌搜索这个问题,我遇到了一些对我来说不起作用的解决方案:
1.使用Datatable设置报表的"SetDataSource"属性,而不使用Dataset
2.遍历CrystalDecisions.CrystalReports.Engine.Table中的每个表以设置每个表的连接信息.
在这种情况下,上述方法均无效.
任何帮助将不胜感激.
thnks
Sid
Hi,
I have a web application which displays report using crystal report 12.0
The problem that I am facing is when I generate a report for records upto 20,000, it is successful, but for records above this, it gives me error as follows:
The report you requested requires further information.
--------------------------------------------------------------------------------
Server name:
Database name:
User name:
Password:
Use Integrated Security
----------------------------------------------------------------------------------
Googling the issue, I came across a couple of solutions which are not working in my case:
1. Using Datatable to set the "SetDataSource" property of the report instead of using Dataset
2. Iterating through each table in CrystalDecisions.CrystalReports.Engine.Table to set the connection info for each of them.
None of the above works in this case.
Any help would be appreciated.
thnks
Sid
推荐答案
Friend Function ViewReport(ByVal sReportName As String, _
Optional ByVal sSelectionFormula As String = "", _
Optional ByVal param As String = "") As Boolean
'Declaring variablesables
Dim intCounter As Integer
Dim intCounter1 As Integer
'Crystal Report's report document object
Dim objReport As New _
CrystalDecisions.CrystalReports.Engine.ReportDocument
'object of table Log on info of Crystal report
Dim ConInfo As New CrystalDecisions.Shared.TableLogOnInfo
'Parameter value object of crystal report
' parameters used for adding the value to parameter.
Dim paraValue As New CrystalDecisions.Shared.ParameterDiscreteValue
'Current parameter value object(collection) of crystal report parameters.
Dim currValue As CrystalDecisions.Shared.ParameterValues
'Sub report object of crystal report.
Dim mySubReportObject As _
CrystalDecisions.CrystalReports.Engine.SubreportObject
'Sub report document of crystal report.
Dim mySubRepDoc As New _
CrystalDecisions.CrystalReports.Engine.ReportDocument
Dim strParValPair() As String
Dim strVal() As String
Dim index As Integer
Try
'Load the report
objReport.Load(sReportName)
'Check if there are parameters or not in report.
intCounter = objReport.DataDefinition.ParameterFields.Count
'As parameter fields collection also picks the selection
' formula which is not the parameter
' so if total parameter count is 1 then we check whether
' its a parameter or selection formula.
If intCounter = 1 Then
If InStr(objReport.DataDefinition.ParameterFields(_
0).ParameterFieldName, ".", CompareMethod.Text) > 0 Then
intCounter = 0
End If
End If
'If there are parameters in report and
'user has passed them then split the
'parameter string and Apply the values
'to their concurrent parameters.
If intCounter > 0 And Trim(param) <> "" Then
strParValPair = param.Split("&")
For index = 0 To UBound(strParValPair)
If InStr(strParValPair(index), "=") > 0 Then
strVal = strParValPair(index).Split("=")
paraValue.Value = strVal(1)
currValue = _
objReport.DataDefinition.ParameterFields(_
strVal(0)).CurrentValues
currValue.Add(paraValue)
objReport.DataDefinition.ParameterFields(_
strVal(0)).ApplyCurrentValues(currValue)
End If
Next
End If
'Set the connection information to ConInfo
'object so that we can apply the
'connection information on each table in the report
ConInfo.ConnectionInfo.UserID = <User Name>
ConInfo.ConnectionInfo.Password = <Password>
ConInfo.ConnectionInfo.ServerName = <Server Name>
ConInfo.ConnectionInfo.DatabaseName = <Database Name>
For intCounter = 0 To objReport.Database.Tables.Count - 1
objReport.Database.Tables(intCounter).ApplyLogOnInfo(ConInfo)
Next
' Loop through each section on the report then look
' through each object in the section
' if the object is a subreport, then apply logon info
' on each table of that sub report
For index = 0 To objReport.ReportDefinition.Sections.Count - 1
For intCounter = 0 To _
objReport.ReportDefinition.Sections(_
index).ReportObjects.Count - 1
With objReport.ReportDefinition.Sections(index)
If .ReportObjects(intCounter).Kind = _
CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then
mySubReportObject = CType(.ReportObjects(intCounter), _
CrystalDecisions.CrystalReports.Engine.SubreportObject)
mySubRepDoc = _
mySubReportObject.OpenSubreport(mySubReportObject.SubreportName)
For intCounter1 = 0 To mySubRepDoc.Database.Tables.Count - 1
mySubRepDoc.Database.Tables(_
intCounter1).ApplyLogOnInfo(_
ConInfo)sp;
mySubRepDoc.Database.Tables(_
intCounter1).ApplyLogOnInfo(ConInfo)
Next
End If
End With
Next
Next
'If there is a selection formula passed to this function then use that
If sSelectionFormula.Length > 0 Then
objReport.RecordSelectionFormula = sSelectionFormula
End If
'Re setting control
rptViewer.ReportSource = Nothing
'Set the current report object to report.
rptViewer.ReportSource = objReport
'Show the report
rptViewer.Show()
Return True
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Function
在设计源中放这个属性,-
In the design source just put this attribute,-
EnableDatabaseLogonPrompt="false"
希望能为您提供帮助.
Hope this can help you.
感谢您的帮助.....
猜猜我解决了这个问题.已经有代码块可以循环访问CrystalDecisions.CrystalReports.Engine中的表,并为每个表提供连接信息.
通过反复试验的方法,我传递了代码块,并在我的情况下起作用.以下是我评论的代码:
/********代码块********************************/
Thnx all for your help.....
Guess i solved the problem. There was already the block of code which iterates through the tables in the CrystalDecisions.CrystalReports.Engine and gives each one of them the Connection info.
Through trial and error method I by passed the block of code and it worked in my case. Below is the code which i commented:
/********Code Block********************************/
repTbls = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table repTbl in repTbls)
{
repTblLogonInfo = repTbl.LogOnInfo;
repTblLogonInfo.ConnectionInfo = connectionInfo;
repTbl.ApplyLogOnInfo(repTblLogonInfo);
}
reportDocument.SetDatabaseLogon(connectionInfo.UserID,connectionInfo.Password,connectionInfo.ServerName,null);
/***************************************************** *****/
/******************************************************/
这篇关于水晶报表问题-登录提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!