我将 VS-2008 用于 asp.net Web 应用程序。但是,我在 VS 2005 中开发了我的报告。(我正在重用在其他项目中开发的一些报告)。
除了不显示图像字段外,报告工作正常。图像字段是数据库中的“VARBINARY(MAX)”字段。请注意,当我将 Crystal Report 导出为 .pdf 时,图像会显示在 .pdf 文件中。
(* 我能够在“Firebug”中看到图像 url,但收到消息“加载图像失败”)
我正在使用“TypedDataset”作为 Crystal Report 的数据源。
我从数据库中获取数据并执行“DataSet.WriteXML(filename,WriteMode.WriteSchema)”
这是代码: -
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim rgx As Regex = New Regex("[^a-zA-Z0-9 -]")
strComp = rgx.Replace(strComp, "")
strFile = "tempXML" + strComp + ".xml"
Dim dsTemp As New DataSet
dsTemp.Clear()
dsTemp.Tables.Clear()
Dim rptengine As New CrystalDecisions.CrystalReports.Engine.ReportDocument
rptengine.Load(Session("rptname"))
sdate = CType(Session("sdate"), Date)
edate = CType(Session("edate"), Date)
rptHeading = Session("rptHead")
If IO.File.Exists(Server.MapPath("~/" + strFile)) Then
dsTemp.ReadXml(Server.MapPath("~/" + strFile), XmlReadMode.ReadSchema)
'IO.File.Delete(Server.MapPath("~/" + strFile))
Try
If Session("rptname").ToString.Substring(Session("rptname").ToString.LastIndexOf("\") + 1) _
= "Rptemp.rpt" Then
Dim dsReport As New DDL.dsEmpList
dsReport.Tables("dtEmpList").Merge(dsTemp.Tables(0))
rptengine.SetDataSource(dsReport.Tables(0))
ElseIf Session("rptname").ToString.Substring(Session("rptname").ToString.LastIndexOf("\") + 1) _
= "rptDailyAttendance.rpt" Then
Dim dsReport As New DDL.dsDailyReoprt
dsReport.Tables("dtDailyReport").Merge(dsTemp.Tables(0))
rptengine.SetDataSource(dsReport.Tables(0))
End If
Catch ex As Exception
ShowMsg1("Exception : " & ex.Message)
End Try
'**********************assigning CR-ParameterFields*****************************
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldDefinition As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim parameterToDefine As Boolean = False
crParameterFieldDefinitions = rptengine.DataDefinition.ParameterFields
For Each crParameterFieldDefinition In crParameterFieldDefinitions
crParameterDiscreteValue = New ParameterDiscreteValue
crParameterValues = crParameterFieldDefinition.CurrentValues
Select Case crParameterFieldDefinition.Name
Case "sdate"
parameterToDefine = True
crParameterDiscreteValue.Value = sdate
Case "edate"
parameterToDefine = True
crParameterDiscreteValue.Value = edate
Case "heading"
parameterToDefine = True
crParameterDiscreteValue.Value = rptHeading
Case Else
parameterToDefine = False
End Select
If parameterToDefine Then
Try
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldDefinition.ApplyCurrentValues(crParameterValues)
Catch ex As Exception
objdata.writelog(ex.Message, "frmRptEngine", "frmRptEngine_Load", Server.MapPath("~/Reports"))
ShowMsg1("Error in report generation.")
Exit Sub
End Try
End If
Next
rptViewer.ReportSource = Nothing
rptViewer.ReportSource = rptengine
rptViewer.Enabled = True
rptViewer.DataBind()
Else
ShowMsg1("Invalid attempt.")
End If
End Sub