cci_john Level: Trainee
 Registered: 16-12-2008 Posts: 1
|
Crystal Report problem
Hi, and HELP!
Here's the short: Using VB.NET 2002, Crystal Reports.NET in a webpage. Exporting the report to PDF to display on the web page and be printable, etc...
It works fine on my PC, but when I install on a server, I get CrystalDecisions.CrystalReports.Engine.DataSourceException: Query Engine Error
The report is reading 2 tables from a dataset (not directly from a file because I'm reading from an AS/400 and I need to incorporate images into the report).
My code is below. Upgrading to newer .net - not an option unfortunately. Any productive help is GREATLY appreciated!
Dim oRpt As New OrderRecapReport() 'the Crystal Report
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
InitializeComponent()
oRpt.Load()
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sPicFilePath As String
Dim drow As DataRow
Dim ds1 As New Dataset2()
Dim crExportOptions As ExportOptions
Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
da.SelectCommand.CommandText = "Select * from WKPCOR1F"
da.Fill(ds1, "WKPCOR1F")
For Each drow In ds1.Tables(0).Rows
If Trim(drow("WFFPI1")) <> "" Then
sPicFilePath = "/OrderRecapReport/Pictures/" & Right(Trim(drow("WFFPI1")), Len(Trim(drow("WFFPI1"))) - 3)
If System.IO.File.Exists(Trim(Server.MapPath(sPicFilePath))) = True Then
Dim fsimage As New FileStream(Server.MapPath(sPicFilePath), FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fsimage)
drow("IMAGE1") = br.ReadBytes(br.BaseStream.Length)
br = Nothing
fsimage.Close()
fsimage = Nothing
End If
End If
If Trim(drow("WFFPI2")) <> "" Then
sPicFilePath = "/OrderRecapReport/Pictures/" & Right(Trim(drow("WFFPI2")), Len(Trim(drow("WFFPI2"))) - 3)
If System.IO.File.Exists(Trim(Server.MapPath(sPicFilePath))) = True Then
Dim fsimage As New FileStream(Server.MapPath(sPicFilePath), FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fsimage)
drow("IMAGE2") = br.ReadBytes(br.BaseStream.Length)
br = Nothing
fsimage.Close()
fsimage = Nothing
End If
End If
If Trim(drow("WFFPI3")) <> "" Then
sPicFilePath = "/OrderRecapReport/Pictures/" & Right(Trim(drow("WFFPI3")), Len(Trim(drow("WFFPI3"))) - 3)
If System.IO.File.Exists(Trim(Server.MapPath(sPicFilePath))) = True Then
Dim fsimage As New FileStream(Server.MapPath(sPicFilePath), FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fsimage)
drow("IMAGE3") = br.ReadBytes(br.BaseStream.Length)
br = Nothing
fsimage.Close()
fsimage = Nothing
End If
End If
If Trim(drow("WFFPI4")) <> "" Then
sPicFilePath = "/OrderRecapReport/Pictures/" & Right(Trim(drow("WFFPI4")), Len(Trim(drow("WFFPI4"))) - 3)
If System.IO.File.Exists(Trim(Server.MapPath(sPicFilePath))) = True Then
Dim fsimage As New FileStream(Server.MapPath(sPicFilePath), FileMode.Open, FileAccess.Read)
Dim br As New BinaryReader(fsimage)
drow("IMAGE4") = br.ReadBytes(br.BaseStream.Length)
br = Nothing
fsimage.Close()
fsimage = Nothing
End If
End If
Next
ds1.AcceptChanges()
da.SelectCommand.CommandText = "SELECT * FROM WKPCOR1G"
da.Fill(ds1, "WKPCOR1G")
ds1.AcceptChanges()
da.Dispose()
cn.Close()
oRpt.SetDataSource(ds1)
crDiskFileDestinationOptions = New DiskFileDestinationOptions()
sReportFile = Server.MapPath("/OrderRecapReport/Temp/" & Session.SessionID.ToString & "StyleDetail.pdf")
crDiskFileDestinationOptions.DiskFileName = sReportFile
crExportOptions = oRpt.ExportOptions
crExportOptions.DestinationOptions = crDiskFileDestinationOptions
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat
oRpt.Export()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/pdf"
Response.WriteFile(sReportFile)
Response.Flush()
Response.Close()
System.IO.File.Delete(sReportFile)
oRpt.Close()
oRpt.Dispose()
End Sub
|