Visual Studio 2010(VB.NET)sap cystal报告查看器 [英] Visual Studio 2010 (VB.NET) sap cystal report viewer
问题描述
请帮助,我们在报告视图中有一个奇怪的问题。
我们有一些报告,当我们尝试预览特定记录时,第一次报告带有详细/页脚部分的complet数据(未使用我们指定的参数进行过滤)。但是如果我们第二次运行相同的报告,直到关闭项目,报告会提供过滤的详细信息/页脚数据,这是正确的和期望的结果。
但是我们无法理解为什么第一次报告有错误的数据(未经过滤)。
此特定问题没有任何错误记录。
Please help, We have a strange problem in report view.
We have some reports, when we try to preview for a particular record, the first time report come with complet data of detail / footer section (without filtered with our assigned parameeter). But if we run the same report second time onwards until closing the project the report comming with filtered detail / footer data, which is the correct and expecting result.
but we could not understand why the first time report come with wrong data (unfiltered).
There is no any error recording for this particular problem.
<pre lang="vb">
Dim cryRpt As New ReportDocument
Dim RepPath As String = GetReportAppPath()
If RepPath = "NoPath" Then
MessageBox.Show("Please set the report location", "Invalid Report Location!", MessageBoxButtons.OK)
Me.Close()
Else
Try
cryRpt.Load(RepPath & ReportName & ".rpt")
Me.Text = ReportName & System.DateTime.Now.Date
Dim _ServerName As String = IP
Dim _DatabaseName As String = DB
Dim _UserID As String = DBID
Dim _Password As String = DBPW
Dim Logon As New TableLogOnInfo
Dim Tbl As Table
For Each Tbl In cryRpt.Database.Tables
Logon = Tbl.LogOnInfo
Logon.ConnectionInfo.ServerName = _ServerName
Logon.ConnectionInfo.DatabaseName = _DatabaseName
Logon.ConnectionInfo.Password = _Password
Logon.ConnectionInfo.UserID = _UserID
Logon.ConnectionInfo.IntegratedSecurity = False
Tbl.ApplyLogOnInfo(Logon)
Next
Dim Subreport As ReportDocument
For Each Subreport In cryRpt.Subreports
For Each Tbl In Subreport.Database.Tables
Logon = Tbl.LogOnInfo
Logon.ConnectionInfo.ServerName = _ServerName
Logon.ConnectionInfo.UserID = _UserID
Logon.ConnectionInfo.Password = _Password
Logon.ConnectionInfo.IntegratedSecurity = False
Tbl.ApplyLogOnInfo(Logon)
Next
Next
Dim val As String = Para1
Dim paramField As New ParameterField
Dim paramDiscreteValue As New ParameterDiscreteValue
Dim paramFields As New ParameterFields
paramField.Name = "para"
paramDiscreteValue.Value = val
paramField.CurrentValues.Add(paramDiscreteValue)
paramFields.Add(paramField)
Select Case ReportName
Case "rptSupRFQ_Normal", "rptSupRFQ_Principle", "rptSupRFQ_Direct", "rptQuotation_preview"
Dim paramField1 As New ParameterField
Dim paramDiscreteValue1 As New ParameterDiscreteValue
paramField1.Name = "ItmDes"
paramDiscreteValue1.Value = frmNewSearch.chkVenderDesc.Checked
paramField1.CurrentValues.Add(paramDiscreteValue1)
paramFields.Add(paramField1)
Case "rptCusDelv_preview", "rptCusInv_preview"
Dim paramField1 As New ParameterField
Dim paramDiscreteValue1 As New ParameterDiscreteValue
paramField1.Name = "type"
paramDiscreteValue1.Value = frmNewSearch.chkOriginal.Checked
paramField1.CurrentValues.Add(paramDiscreteValue1)
paramFields.Add(paramField1)
End Select
CrystalReportViewer1.ParameterFieldInfo = paramFields
CrystalReportViewer1.ReportSource = cryRpt
CrystalReportViewer1.Refresh()
Catch ex As Exception
el.WriteToErrorLog(ex.Message)
Me.Close()
End Try
End If
</pre>
推荐答案
在水晶报表中添加参数,然后传递代码中的值。
之后在报告中添加参数添加以下代码
paramField1.SetParameterValue(ItmDes,paramDiscreteValue1)
谢谢
Nitish
Add your parameter in the crystal report and then pass the value from your code.
After adding parameter in report add the bellow code
paramField1.SetParameterValue("ItmDes", paramDiscreteValue1)
Thanks
Nitish
验证使用报告保存数据 [ ^ ]选项未选中。
编辑
------------
同意第二个解决方案,订单错误。添加后你必须传递值。
VB.NET Crystal Reports字符串参数 [ ^ ]
Verify Save Data With Report[^] option is unchecked.
EDIT
------------
Agree with 2nd solution, the order is wrong. You have to pass value after adding that.
VB.NET Crystal Reports String parameter[^]
这篇关于Visual Studio 2010(VB.NET)sap cystal报告查看器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!