我还在Crystal Reports论坛中发布了此question,但尚无答案。我有一个最初使用Crystal Reports 2008在VS 2008中编写的应用程序。原始代码没有问题。
与此帖子类似:Error message that says "No Error" from CR Viewer,我刚刚将应用程序升级到.net 4.0和Crystal Reports 2010.报表查看器在第一次加载报表时工作正常,但是当我更改参数时报告,并将更新的报告放回报告查看器,我在弹出窗口中显示上面显示的消息。报告不会更改其参数,也不会显示更新的报告。有问题的代码是设置报告的日期参数。用户可以从包含报表查看器的表单中选择新的日期参数。代码将Report Object代码子类化,以通过接口添加其他功能。 IDateRange界面使用报表类的属性为报表提供开始和结束日期范围,如下所示:
Public Property EndingDate() As Date Implements IDateRange.EndingDate
Get
Return _endingDate
End Get
Set(ByVal value As Date)
_endingDate = value
Me.SetParameterValue("EndingDate", value)
End Set
End Property
此外,即时窗口显示以下消息:
CrystalDecisions.CrystalReports.Engine.dll中出现'System.Runtime.InteropServices.COMException'类型的第一次机会异常
报告查看器中的代码如下所示,弹出窗口时设置查看器报告源的行:
''' <summary>
''' Sets the report period and displays it.
''' </summary>
''' <param name="Report">The Report.</param>
''' <param name="Refresh">if set to <c>true</c> force a refresh.</param>
Private Function PFSetReportPeriod(ByVal Report As Object, Optional ByVal Refresh As Boolean = True) As Boolean
Dim fld As FormulaFieldDefinition
Dim bRefresh As Boolean = False
Dim rpt As ReportClass = CType(Report, ReportClass)
Try
If TypeOf rpt Is IDateRange Then
With DirectCast(rpt, IDateRange)
StartingDate = dtpFromDate.Value
EndingDate = dtpToDate.Value
End With
SetTitleLine2(DirectCast(Report, ReportClass), bRefresh)
bRefresh = True
Else
If TypeOf rpt Is ReportClass Then
fld = rpt.DataDefinition.FormulaFields("FromDate")
If Not fld Is Nothing Then
fld.Text = "Date(" & dtpFromDate.Value.Year & "," & dtpFromDate.Value.Month & "," & dtpFromDate.Value.Day & ")"
bRefresh = True
End If
fld = rpt.DataDefinition.FormulaFields("ToDate")
If Not fld Is Nothing Then
fld.Text = "Date(" & dtpToDate.Value.Year & "," & dtpToDate.Value.Month & "," & dtpToDate.Value.Day & ")"
bRefresh = True
End If
SetTitleLine2(rpt, bRefresh)
End If
End If
If Refresh And bRefresh Then
If dtpToDate.Value <> CDate(dtpToDate.Tag) OrElse _
dtpFromDate.Value <> CDate(dtpFromDate.Tag) Then
System.Windows.Forms.Application.DoEvents()
If CRV.Visible Then CRV.ReportSource = rpt ' The popup appears when this statement is executed.
If CRV.Visible = True Then CRV.Refresh()
dtpToDate.Tag = dtpToDate.Value
dtpFromDate.Tag = dtpFromDate.Value
Return True
End If
End If
Catch ex As Exception
DisplayException(ex)
End Try
Return False
End Function
我也试过从其他网站推荐的这种技术 - 没有结果 - 我仍然得到弹出窗口:
CRV.ParameterFieldInfo.Clear()
If CRV.Visible Then CRV.ReportSource = rpt
答案 0 :(得分:0)
问题已经解决。我从这个location下载了Support Pack 8(v.13.0.8.1216)。然后我从上面的条目中应用了修复:
With CRV ' Report Viewer Control
If .Visible Then
If .ParameterFieldInfo IsNot Nothing Then .ParameterFieldInfo.Clear()
.ReportSource = rpt
.Refresh()
End If
End With
不再烦人的“无错误”消息。