cancel
Showing results for 
Search instead for 
Did you mean: 

My Report Fails once it is exported

Former Member
0 Kudos

I am using crystal reports that come with visual studio 2008 and i also tested with visual studio 2005.

I have a report and i can view any number of reports but when i export the report as pdf or any other format.The next report fails. Is there a solution to address this problem . I am just using the crystal reports viewer to show the report.

This is a windows application hence i am using the reportviewer that comes with the visual studio to show the report and using the menubar button to export the report.

The error i get is simple "LOAD REPORT FAILED"

Any Help???????????

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Please make sure that you are loading the report in report document object properly. One thing is to check if the path of the report is proper.

Also make sure that you are redefining the reportdocument object before selecting the report. Is it possible to share your code?

Here is the code that works fine at my end:

ReportDocument rdoc = new ReportDocument();

rdoc.Load("C:
Temp
Report.rpt");

CrystalReportViewer1.ReportSource = rdoc;

Regards,

AG.

Former Member
0 Kudos

Thanks AG .

My Problem is not loading the report for the first time . I can view any number of reports by changing the search criteria. But If i use the export icon in crystal report viewer to save it into the any available format. It is fine till then.

If i cange the search criteria again and when i try to view the report again then it fails to load.

Do you know y ??

Former Member
0 Kudos

Dim cr As New ReportDocument

Dim crtableLogoninfos As New TableLogOnInfos

Dim crtableLogoninfo As New TableLogOnInfo

Dim crConnectionInfo As New ConnectionInfo

Dim CrTables As Tables

Dim CrTable As Table

cr.Load(pRptName)

CrystalReportViewer1

.ReportSource = cr

This is the code i am using.

Former Member
0 Kudos

No sure what is going wrong at your end. Here is the code that I used and it worked fine for multiple exporting.

using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Windows;
using CrystalDecisions.Shared;

private void Form1_Load(object sender, EventArgs e)
        {
            ReportDocument rdoc = new ReportDocument();
            rdoc.Load(@"C:\Program Files\Microsoft Visual Studio 9.0\Crystal Reports\Samples\En\Reports\General Business\Employee Profile.rpt");
            crystalReportViewer1.ReportSource = rdoc;

        }

try the same in a simple app then move to your project.

Regards,

AG.

former_member183750
Active Contributor
0 Kudos

Your code does not really show much - I don't think that is the full code as it applies to CR(?). Not sure why you dim all the database logon objects(?).

I would suggest downloading our sample apps from here:

https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe

Use the sample vbnet_win_simplepreview and see if you can duplicate the issue.

Also, specify what version of CR you are using.

What version of .NET you are using.

What SP for CR has been applied.

Ludek

Former Member
0 Kudos

Dim cr As New ReportDocument

Dim crtableLogoninfos As New TableLogOnInfos

Dim crtableLogoninfo As New TableLogOnInfo

     
   Dim crConnectionInfo As New ConnectionInfo
        Dim CrTables As Tables
        Dim CrTable As Table

        cr.Load(pRptName)

        'Get database connection info
        With crConnectionInfo
            .ServerName = My.Settings.ConnectionString.Split(";")(0).Split("=")(1)
            .DatabaseName = My.Settings.ConnectionString.Split(";")(1).Split("=")(1)
            .UserID = My.Settings.ConnectionString.Split(";")(3).Split("=")(1)
            .Password = My.Settings.ConnectionString.Split(";")(4).Split("=")(1)
        End With

        'Set database connection for all tables in report
        CrTables = cr.Database.Tables
        For Each CrTable In CrTables
            crtableLogoninfo = CrTable.LogOnInfo
            crtableLogoninfo.ConnectionInfo = crConnectionInfo
            CrTable.ApplyLogOnInfo(crtableLogoninfo)
        Next

        ' Loop through each section and find report objects  
        Dim crReportobjects As ReportObjects, crSubReportobject As SubreportObject, subReportDocument As ReportDocument
        Dim crDatabase As Database
        Dim crSections As Sections = cr.ReportDefinition.Sections
        For Each crSection As Section In crSections
            crReportobjects = crSection.ReportObjects
            For Each crReportobject As ReportObject In crReportobjects
                If crReportobject.Kind = ReportObjectKind.SubreportObject Then
                    ' If a subreport is found cast as subreportobject                        
                    crSubReportobject = CType(crReportobject, SubreportObject)
                    ' Open the sub report                        
                    subReportDocument = crSubReportobject.OpenSubreport(crSubReportobject.SubreportName)
                    crDatabase = subReportDocument.Database
                    CrTables = crDatabase.Tables
                    ' Loop through each table in the sub report and set the connection info                        
                    For Each CrTable In CrTables
                        crtableLogoninfo = CrTable.LogOnInfo
                        crtableLogoninfo.ConnectionInfo = crConnectionInfo
                        CrTable.ApplyLogOnInfo(crtableLogoninfo)
                    Next
                End If
            Next
        Next


        If Not chkSelectClient.Checked Then
            'Show all invoices
            cr.RecordSelectionFormula = "{Invoices.invoice_date} in {?StartDate} to {?EndDate} and {Subject_Names.primary_name} and {Clients.billing_cycle} = {?Filter_BillingCycle}"
        Else
            'Invoice Number report parameter
            cr.SetParameterValue("Filter_InvoiceNumber", Me.cboInvoices.Text.Trim)
            cr.RecordSelectionFormula = "{Subject_Names.primary_name} and {Invoices.invoice_number} = {?Filter_InvoiceNumber} and {Clients.billing_cycle} = {?Filter_BillingCycle}"
        End If

        'Set report parameters
        cr.SetParameterValue("StartDate", Me.dtpStart.Value)
        cr.SetParameterValue("EndDate", Me.dtpEnd.Value)
        cr.SetParameterValue("Filter_BillingCycle", IIf(Me.optMonthly.Checked, "Monthly", "Weekly"))
        'cr.SetParameterValue("location_id", Me.locationNameComboBox.SelectedValue                  cr.SetParameterValue("Billing_Contact", Billing_Contact.ToString())
     


        'Show report
        With CrystalReportViewer1
            .ReportSource = cr
            .Zoom(100)
            .DisplayGroupTree = False
            .Visible = True
            .Refresh()
        End With

This is the complete code for my report and i use it and i can view any number of reports before exporting.

I am using visual studio 2008 and crystal reports 10.5 that comes with the VS2008 and i have applied servicepack 1 .

If you need any more details let me know

Edited by: manojbavikati on May 13, 2009 4:24 PM

former_member183750
Active Contributor
0 Kudos

Righ, I don't think that came in quite right...(?). Repost ensuring the post is readable. Also, do try the sample app too.

If these suggestions are not of any help to you, consider obtaining a single phone support contract from here:

http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryI...

Ludek

Former Member
0 Kudos


I tried but i didnt come out well .Thanks for the help.















Former Member
0 Kudos

I am not able to format it . I am sorry but thats the code. i have used for all the reports and they work fine until they are exported

Edited by: manojbavikati on May 13, 2009 5:46 PM

former_member183750
Active Contributor
0 Kudos

Looks to me like you're stuck with two options:

1) Try one of our sample apps

2) Obtain a online support

I really can not go through the code as it is and it may not be the issue in the 1st place.

Ludek

Former Member
0 Kudos

Where can i get online support ??

former_member183750
Active Contributor
0 Kudos

The link is in my post from May 13, 2009 7:53 AM on this thread.

Ludek

0 Kudos

Hello,

I think the problem is once you are finished with the report you need to close and dispose your report object. I copied your code into VB .NET and I think I have most of it but not sure.

Which Viewer are you using? In your references are you using CrystalDecisions.Windows.Forms or did you try using the crviewer.dll?

Dim cr As New ReportDocument

Dim crtableLogoninfos As New TableLogOnInfos

Dim crtableLogoninfo As New TableLogOnInfo '

Dim crConnectionInfo As New ConnectionInfo

Dim CrTables As Tables

Dim CrTable As Table

cr.Load(pRptName)

'Get database connection info

With crConnectionInfo.ServerName = My.Settings.ConnectionString.Split(";")(0).Split("=")(1)

.DatabaseName = My.Settings.ConnectionString.Split(";")(1).Split("=")(1)

.UserID = My.Settings.ConnectionString.Split(";")(3).Split("=")(1)

.Password = My.Settings.ConnectionString.Split(";")(4).Split("=")(1)

End With

'Set database connection for all tables in report

CrTables = cr.Database.Tables

For Each CrTable In CrTables

crtableLogoninfo = CrTable.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo

CrTable.ApplyLogOnInfo(crtableLogoninfo)

Next

' Loop through each section and find report objects

Dim crReportobjects As ReportObjects, crSubReportobject As SubreportObject, subReportDocument As ReportDocument

Dim crDatabase As Database

Dim crSections As Sections = cr.ReportDefinition.Sections

For Each crSection As Section In crSections

crReportobjects = crSection.ReportObjects

For Each crReportobject As ReportObject In crReportobjects

If crReportobject.Kind = ReportObjectKind.SubreportObject Then

' If a subreport is found cast as subreportobject

crSubReportobject = CType(crReportobject, SubreportObject)

'Open the sub report

subReportDocument = crSubReportobject.OpenSubreport(crSubReportobject.SubreportName)

crDatabase = subReportDocument.Database

CrTables = crDatabase.Tables

' Loop through each table in the sub report and set the connection info

For Each CrTable In CrTables

crtableLogoninfo = CrTable.LogOnInfo

crtableLogoninfo.ConnectionInfo = crConnectionInfo

CrTable.ApplyLogOnInfo(crtableLogoninfo)

Next

End If

Next

Next

If Not chkSelectClient.Checked Then

'Show all invoices

cr.RecordSelectionFormula = "{Invoices.invoice_date} in {?StartDate} to {?EndDate} and {Subject_Names.primary_name} and {Clients.billing_cycle} = {?Filter_BillingCycle}"

Else 'Invoice Number report parameter cr.SetParameterValue("Filter_InvoiceNumber", Me.cboInvoices.Text.Trim)

cr.RecordSelectionFormula = "{Subject_Names.primary_name} and {Invoices.invoice_number} = {?Filter_InvoiceNumber} and {Clients.billing_cycle} = {?Filter_BillingCycle}"

End If

'Set report parameters

cr.SetParameterValue("StartDate", Me.dtpStart.Value)

cr.SetParameterValue("EndDate", Me.dtpEnd.Value)

cr.SetParameterValue("Filter_BillingCycle", I If(Me.optMonthly.Checked, "Monthly", "Weekly"))

cr.SetParameterValue("location_id", Me.locationNameComboBox.SelectedValue cr.SetParameterValue("Billing_Contact", Billing_Contact.ToString())

'Show report

With CrystalReportViewer1

.ReportSource = cr

.Zoom(100)

.DisplayGroupTree = False

.Visible = True

.Refresh()

End With

End Sub

Thank you

Don

Former Member
0 Kudos

i am using crystal report viewer to view the report and so i have imported the references as below


Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports CrystalDecisions.Windows

If i dispose the report once it is generated then i cant navigate to the next page. It says object reference set to null. so i didnt use it here .

I am using crystal reports that come with vs2008 .

I think it uses crystal reports 10.5 assemblies.

Former Member
0 Kudos

Hi,

I believe we all are trying to make one point: Make it simple!

Just take a Sample report. then use it and then just use your report, let it refer to the same connection that it is created in the designer, prompt etc.

Once that works go in code.

Hope that helps!.

Thanks.

AG.

Former Member
0 Kudos

I tried but no luck ..It still did the same.

Answers (1)

Answers (1)

Former Member
0 Kudos

Used cr as reportdocument()

insted used cr as reportname()

this fixed my problem