Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Crystal.. Problem with the Export

Posted on 2010-08-14
2
Medium Priority
?
212 Views
Last Modified: 2013-11-26
i have this error.
Object reference not set to an instance of an object.

Three things irksome about this error..

1) All was working fine I tweeked stuff not at all involved with this module or code and have an issue.
3) you can see I instatited a new instence in the first code line of the "try"
2) I could understand if this was a message at the first use of the field.. But it is not.. I load it, add parameter info to it.. Then it blows at the last line.. crReportDocument.Export();

public void CreateEnglishPdf(string ReportPathAndName, string PDFPathAndName, string UnitType,string UnitNo,
         string Name_SP_Table, DataSet ds,string rptType)
    {
        this.Name_SP_Table = Name_SP_Table;
        this.UnitType = UnitType;
        this.UnitNo = UnitNo;
        
        //Call the report from its stored directory
        try
        {
            //setStoredProcedure(Name_SP_Table);
            //Reportdataset = ds;
            //setDataset(UnitType,UnitNo);
            crReportDocument = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            crReportDocument.Load(ReportPathAndName);

            //Apply logon information to the main report and all sub reports
            setLogon();
            //UnitType
            ParameterValues ParmValue = new ParameterValues();
            ParameterDiscreteValue ParamDiscreteValue = new ParameterDiscreteValue();
            ParamDiscreteValue.Value = UnitType;
            ParmValue.Add(ParamDiscreteValue);
            crReportDocument.DataDefinition.ParameterFields["@UnitType"].ApplyCurrentValues(ParmValue);
            //crReportDocument.SetParameterValue("@UnitType", UnitType); 
            //UnitNo
            ParameterValues ParmValue2 = new ParameterValues();
            ParameterDiscreteValue ParamDiscreteValue2 = new ParameterDiscreteValue();
            ParamDiscreteValue2.Value = UnitNo;
            ParmValue2.Add(ParamDiscreteValue2);
            crReportDocument.DataDefinition.ParameterFields["@UnitNo"].ApplyCurrentValues(ParmValue2);
            //crReportDocument.SetParameterValue("@UnitNo", UnitNo); 

            crDiskFileDestinationOptions = new DiskFileDestinationOptions();
            crDiskFileDestinationOptions.DiskFileName = PDFPathAndName;
            crExportOptions = crReportDocument.ExportOptions;
            crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
            crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
            if (rptType == "PDF")
            {
                crExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
            }
            else if (rptType == "doc")
            {
                crExportOptions.ExportFormatType = ExportFormatType.WordForWindows;
            }

            crReportDocument.Export();

        }
        catch (Exception)
        {
            throw;
        }
        finally
        {
            crReportDocument.Close();
            crReportDocument.Dispose();
        }

Open in new window

0
Comment
Question by:moosetracker
2 Comments
 
LVL 16

Accepted Solution

by:
Vikram Singh Saini earned 2000 total points
ID: 33439983
Hi,

I have some questions about your problem:

(1) In which line exception raised?

(2) Are you sure string ReportPathAndName is not null?

(3) "I tweeked stuff not  at all involved with this module" So what is that stuff?

Regards,
V.S.Saini
0
 
LVL 1

Author Closing Comment

by:moosetracker
ID: 33440547
Found it, but thanks for the attempt.. And it was in the tweeking.
I altered the Stored Procedure that a CR was loading from.. this caused I don't know what, but the end of the SP had a Select statement that defined the Fields of the CR.. When I tested the SP in SQL all looked good, Select statement created the output. But CR no longer liked it. I went in and said update the Datasource, CR says "Datasource updated" no problem.. But, the table is now a no field table (which it doesn't even tell me I lost fields I ame using while updating..)  Just when you run it blows up, but not with a recognizable error..

Could never fix the SP and have the modifications I wanted (which involved no change to field layout, but more update queries to filter the data).. So I pushed the results to a table, and had crystal link to the table.
0

Featured Post

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question