Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3523

Issue with exporting or previewing report in vb.net (VS2013) using crystal reports 2013

$
0
0

I have looked for a solution with no luck for a week.  The code is upgraded from vb6 to .net and the upgrade of crystal reports 9 to crystal 2013.

 

The crystal report works fine when viewing in Crystal 2013 - I am connecting to an Oracle database using an ADO connection.  I have about 40 reports that were written in Crystal 9 upgraded to Crystal 2013.  I can preview data in Crystal 2013 with no issues.

 

The issue is in vb.net 2013 ...when I try to view the report in the report viewer the error is "Failed to retrieve data from the database" "Database vendor code 942"  I have verified the sql statement returns data when ran in a query tool.

 

When I try to export the report to pdf - I get the error "The system cannot find the path specified"

 

The error only occurs at the point of trying to view or export.

Any help would be appreciated.  Advise on References, etc.

Thanks!

Brenda

 

My code:

Dim CRFormulas As CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinitions

Dim CRFormula As CrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition

 

strEmail = "C:\Portstat_email"

 

New CrystalDecisions.CrystalReports.Engine.ReportDocument

 

CRrpt.Load(gPerfRptPath)

 

LogOnToDatabase((CRrpt))

'Code for LogOnToDatabase at bottom of this page

 

        CRrpt.SetParameterValue("User Id", gsUserId)

        CRrpt.SetParameterValue("AcctId", gsAcctId)

 

        CRFormulas = CRrpt.DataDefinition.FormulaFields

 

For Each CRFormula In CRFormulas

            If CRFormula.Name = "ReceiveToDate" Then

                CRFormula.Text = "'" & CDate(frmMain.txtToDate.Text) & "'"

            End If

        Next CRFormula

 

'Preview
        If ToScreen Then
            frmPreview.CrystalReportViewer1.ReportSource = CRrpt
            frmPreview.Show()
            frmPreview.CrystalReportViewer1.Show()


        ElseIf TOEmail Then

            CRrpt.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, strEmail & "\Performance.pdf")

        Else
            CRrpt.PrintToPrinter(CShort(frmMain.txtCopies.Text), False, 0, 0)
        End If

 

 

'Code for LogOnToDatabase

 

Public Sub LogOnToDatabase(ByRef pCrystalReport As CrystalDecisions.CrystalReports.Engine.ReportDocument)
Dim objTableLogonInfo As CrystalDecisions.Shared.TableLogOnInfo

Dim objDatabaseTable As CrystalDecisions.CrystalReports.Engine.Table

Dim objCrSection As CrystalDecisions.CrystalReports.Engine.Section

Dim objCrReportObject As CrystalDecisions.CrystalReports.Engine.ReportObject

Dim objCrSubreportObject As CrystalDecisions.CrystalReports.Engine.SubreportObject

Dim objCrSubreport As CrystalDecisions.CrystalReports.Engine.ReportDocument

 

objTableLogonInfo = New CrystalDecisions.Shared.TableLogOnInfo

objTableLogonInfo.ConnectionInfo.UserID = gsUser

objTableLogonInfo.ConnectionInfo.Password = gsPass

objTableLogonInfo.ConnectionInfo.ServerName = gsServer

objTableLogonInfo.ConnectionInfo.DatabaseName = ""

 

ForEach objDatabaseTable In pCrystalReport.Database.Tables

     objDatabaseTable.ApplyLogOnInfo(objTableLogonInfo)

Next objDatabaseTable

 

        For Each objCrSection In pCrystalReport.ReportDefinition.Sections


            For Each objCrReportObject In objCrSection.ReportObjects


                If objCrReportObject.Kind = CrystalDecisions.Shared.ReportObjectKind.SubreportObject Then


                    objCrSubreportObject = objCrReportObject

  
                    objCrSubreport = objCrSubreportObject.OpenSubreport(objCrSubreportObject.SubreportName)

            
                    For Each objDatabaseTable In objCrSubreport.Database.Tables
                        objDatabaseTable.ApplyLogOnInfo(objTableLogonInfo)
                    Next objDatabaseTable

                End If


            Next objCrReportObject
        Next objCrSection
    End Sub

 

 



Viewing all articles
Browse latest Browse all 3523

Trending Articles