cancel
Showing results for 
Search instead for 
Did you mean: 

CR 2010/VS 2008 Navigation Problem - Object reference not set to an instanc

davidperry4
Participant
0 Kudos

I am trying to display a report in an ASP.NET website. I have Crystal Reports 2010 installed and I am developing in VS 2008. I have a report that is bound to a ADO.NET Dataset. At runtime, I set the report datasource to a dataset I fill from an SQL query. The Crystal Viewer shows the first page but if I try to navigate to the next page, I get the following error:

Logon failed. Details: crdb_adoplus : Object reference not set to an instance of an object. Error in File C:\Users\dperry\AppData\Local\Temp\MD-RentComplaint {3BC40AC8-09CB-4530-A32F-DCF427468D28}.rpt: Unable to connect: incorrect log on parameters.

The report is not bound to a database object so why am I getting a Logon failed error?

Here is my code to set the report source:

ReportInfo ri = Session["ReportInfo"] as ReportInfo;

if (ri == null) return;

Page.Title = ri.ReportTitle;

ReportDocument rdoc = new ReportDocument();

rdoc.Load(Server.MapPath("~/system/reports/rpt-files/" + ri.ReportName + ".rpt"));

rdoc.SetDataSource(ri.Datasource);

rdoc.Refresh();

CrystalReportViewer1.ReportSource = rdoc;

CrystalReportViewer1.RefreshReport();

Thanks in advance for your help.

Accepted Solutions (1)

Accepted Solutions (1)

davidperry4
Participant
0 Kudos

I installed CR 2008 SP1 and now I don't get an error message when navigating away from page 1 but the subsequent pages are blank.

If I initialize the ReportDocument on the initial page load and store it in a session variable that I use to set the CrystalViewer ReportSource on subsequent postbacks, everything works as expected. It doesn't seem that I should have to do that as I would expect the Viewer to handle that internally. Does the CrystalViewer require the ReportSource to be set on every postback?

former_member188030
Active Contributor
0 Kudos

The application flow should be-

1. Initialize the ReportDocument object.

2. Load the crystal report into the ReportDocument object.

3. Add the ReportDocument object to session.

4. Assign the ReportDocument object to the CR Viewer as a reportsource.

Hope this helps,

Bhushan.

davidperry4
Participant
0 Kudos

Thanks again for your help. Just to be clear, the ReportDocument object in Session has to be assigned to ReportSource on initial page load and every postback (step 4), correct?

former_member188030
Active Contributor
0 Kudos

Take a look at the below code snippet

if(Session["hierarchicalGroupingReport"] == null)
        {
           hierarchicalGroupingReport = new ReportDocument();
           hierarchicalGroupingReport.Load(Server.MapPath("Hierarchical Grouping.rpt"));
           Session["hierarchicalGroupingReport"] = hierarchicalGroupingReport;
        }
        else
        {
            hierarchicalGroupingReport = (ReportDocument)Session["hierarchicalGroupingReport"];
        }
        crystalReportViewer.ReportSource = hierarchicalGroupingReport;

Hope this helps,

Bhushan.

davidperry4
Participant
0 Kudos

Thanks for clarifying that. My report page works properly now.

Answers (2)

Answers (2)

davidperry4
Participant
0 Kudos

Thanks for the reply. In my VS 2008 project, it is referencing version 10.5.3700.0 so it looks like the correct version. Sorry for the confusion. I have VS 2008 and VS 2010 installed on the same development machine running Windows 7. I installed SAP Crystal Reports for Visual Studio 2010 so I have both installed. Can both versions be installed on the same machine?

In the report designer, the report shows sample data since I am not binding to a database, just an ADO.NET dataset. At runtime, I know the single table in the dataset has 39 records. Additionally, I can see the first record when I open the report.

Maybe I need to apply CR 2008 patches?

former_member188030
Active Contributor
0 Kudos

Hi,

What is the Crystal Reports version you are using, as I am not sure what Crystal Reports 2010 is.

VS 2008 is compatible with only CR for VS 2008 (10.5) and Crystal Reports 2008(12.0).

Few steps you could try-

-If the report is already designed with the database fields in the CR designer and only data is being passed through the code, check if the report works fine in the designer.

- Try and print the dataset, see if it returns the entire data.

- Try the query directly against database ad see if it works fine.

Thanks,

Bhushan.