Skip to Content
author's profile photo Former Member
Former Member

Query Engine Error with CR9.net & VB.NET 2002

P-L-E-A-S-E help. This is an ASP.NET web application that of course works on my development PC, but not on the server where I've installed it.

I'm developing on a WinXP PC, installing on Win Small Business Server 2003.

I'm using the CR9 that came with VS.NET 2002.

What I'm trying to do is export to PDF a report that reads from a dataset. The error I get is: CrystalDecisions.CrystalReports.Engine.DataSourceException: Query Engine Error 'C:\WINDOWS\TEMP\temp.....rpt'

Here's the code in question:

Dim oRpt As New OrderRecapReport2()

Dim sPicFilePath As String

Dim drow As DataRow

Dim dsF As New WKPCOR1F()

Dim dsG As New WKPCOR1G()

Dim crExportOptions As ExportOptions

Dim crDiskFileDestinationOptions As DiskFileDestinationOptions

daF.SelectCommand.CommandText = "Select * from WKPCOR1F"

daF.Fill(dsF, "WKPCOR1F")

For Each drow In dsF.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

dsF.AcceptChanges()

daG.SelectCommand.CommandText = "SELECT * FROM WKPCOR1G"

daG.Fill(dsG, "WKPCOR1G")

dsG.AcceptChanges()

daF.Dispose()

daG.Dispose()

cn.Close()

oRpt.Database.Tables("WKPCOR1F").SetDataSource(dsF)

oRpt.Database.Tables("WKPCOR1G").SetDataSource(dsG)

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()

I've been working on this problem for about a month now and am VERY tired of it. Any help is greatly appreciated!

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Dec 18, 2008 at 02:50 PM

    First, make sure you are using the latest runtime from here:

    https://smpdl.sap-ag.de/~sapidp/012002523100006009302008E/cr_net_2003_mm_en.zip

    Next. In code you are setting two datasets. I'm not sure why? If the report contains two tables, you should be able to create a single dataset and pass that to the report. Remeber it is highly recommended that the tables be linked. If one table is in a main report and the second table is in a subreport, you will have to point the subreport at the second dataset.

    A good troubleshooting technique for issues with datasets is described in a number of posts on this forum, but here is my recommendation:

    1) Just before you pass the dataset to the report, write it out to an XML file:

    myDataset.WriteXml(xmlPath, XmlWriteMode.WriteSchema)

    2) Do the above for both datasets. E.g;

    dsF.WriteXml(xmlPath, XmlWriteMode.WriteSchema)

    oRpt.Database.Tables("WKPCOR1F").SetDataSource(dsF)

    dsG.WriteXml(xmlPath, XmlWriteMode.WriteSchema)

    oRpt.Database.Tables("WKPCOR1G").SetDataSource(dsG)

    3) In the .NET IDE open the report in the design view

    4) Right click on any unused space and choose Database | Set database location

    5) Set the report to the above created XML files (in the "replace with" pane)

    6) Preview the report

    You will probably receive some errors, possibly a field mapping dialog. Field mapping dialog would indicate format differences between what the report expects and what is being passed to it and you will have to resolve those differences.

    Ludek

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 18, 2008 at 02:46 PM

    Hello John,

    In your code it looks like you're filling your datasets, and then disposing of them before you use them in the .SetDataSource method.

    ...
    daG.Fill(dsG, "WKPCOR1G")
    dsG.AcceptChanges()
    daF.Dispose()
    daG.Dispose()
    cn.Close()
    
    oRpt.Database.Tables("WKPCOR1F").SetDataSource(dsF)
    oRpt.Database.Tables("WKPCOR1G").SetDataSource(dsG)
    ...

    Please try commenting out the .Dispose methods and test the application.

    Also, for troubleshooting it might be helpful to move your code into a simple windows application an then pass the Report Object to the Crystal Report Viewer.

    Sincerely,

    Dan Kelleher

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.