I am trying to convert an application built by someone that has left our organization. The app was written in VB in VS2002. This is one of several that I am converting; others have gone fine. The reason we are converting the apps is because the server they are on is dying and we need to move them to a more consolidated share structure on a new server. The problem that I have run into is in a part of her code that runs a Crystal Report that has two different parts, Part1 and Part2 (as I'll refer to them). The .NET front-end is connected to an Access db backend with her customized queries inside also.
The report works fine in the VS2002 version of the program and the second half of the report (Part2) runs fine in my VS2005 converted program. The code in the two procedures is basically identical except for the report queries they run. (I have even tried swapping the queries out in the code and it stills gives me the same error) In debug mode, the line it fails on has the exact same result in it also for both procedures. The two procedures even pick up the same same queried value for their variables, which get populated in both successfully, but it just fails at the very end, right when it is supposed to print the first report page, with the following error:
CrystalDecisions.CrystalReports.Engine.FormulaException was caught Message="
Error in File C:\DOCUME~1\akomarek\LOCALS~1\Temp\temp_5b508b45-188e-45e9-81e6-939521728ba1 {E33AF2AD-BB1F-4270-BCDE-6ED2D8B9EEFB}.rpt:
SQL Expression error: Error in compiling SQL Expression : SQL Expressions can not be used in this report..." Source="CrystalDecisions.ReportAppServer.DataSetConversion"
StackTrace: at CrystalDecisions.ReportAppServer.ConvertDotNetToErom.ThrowDotNetException(Exception e) at CrystalDecisions.ReportSource.EromReportSourceBase.GetLastPageNumber(ReportPageRequestContext reqContext) at CrystalDecisions.CrystalReports.Engine.FormatEngine.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at CrystalDecisions.CrystalReports.Engine.ReportDocument.PrintToPrinter(Int32 nCopies, Boolean collated, Int32 startPageN, Int32 endPageN) at PayReqProject.frmPayReqRpt.BindFirstReport() in C:\PROJECTS\Payroll\PayReqProject\frmPayReqRpt.vb:line 101
The offending line 101 is: oRpt.PrintToPrinter(1, False, 0, 0)
Here is the code from Part1:
Private Sub BindFirstReport() Dim strOleDB As String Dim cnOleDB As New OleDbConnection(m_strConnectionString) Dim dsOleDB As New DataSet() Dim oRpt As New rptPaymentRequest() Dim daOleDB As New OleDbDataAdapter(strOleDB, cnOleDB) Try ' Build Select statement to query invoices from tblInvoices strOleDB = "SELECT * FROM qryFindPayReqsForBatchNbr WHERE BatchNbr = " & m_intBatchNbr & ";" daOleDB.Fill(dsOleDB, "qryFindPayReqsForBatchNbr") 'Uncomment the following line to write out what is being returned so you can compare it to what you you are getting if you have errors 'dsOleDB.WriteXmlSchema("c:\payreq_schema_test.xml") oRpt.SetDataSource(dsOleDB) 'This code allows the report to go directly to the printer without previewing oRpt.RecordSelectionFormula = " {qryFindPayReqsForBatchNbr.BatchNbr} = " & CStr(m_intBatchNbr) & " " oRpt.PrintToPrinter(1, False, 0, 0) *************FAILS ON THIS LINE************** ''This code would allow you to preview the report with the viewer before printing 'CrystalReportViewer1.ReportSource = oRpt 'CrystalReportViewer1.SelectionFormula = " {qryFindPayReqsForBatchNbr.BatchNbr} = " & CStr(m_intBatchNbr) & " " 'CrystalReportViewer1.RefreshReport() 'CrystalReportViewer1.DisplayGroupTree = False Catch e As OleDbException MsgBox(e.Message, MsgBoxStyle.Critical, "OleDB Error") Catch e As Exception MsgBox(e.Message, MsgBoxStyle.Critical, "General Error") End Try End Sub
I tried the report preview code (with the print commented out) and got the same error message.
I have been working to resolve this for many hours and am at a loss; any light anyone can shine on this for me would be greatly appreciated.
Thanks in advance,
Al
Message was edited by: Ludek Uher