Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Crystal Reports - Object reference not set to an instance of an object

Posted on 2014-04-25
Medium Priority
Last Modified: 2014-04-30
Crystal Reports 2008 SP4
Visual Studio 2005

Getting an "Object reference not set to an instance of an object." error when trying to export my report to a pdf.

using (ReportDocument report = new ReportDocument())
    CrystalDecisions.CrystalReports.Engine.TextObject txtNotes = ((CrystalDecisions.CrystalReports.Engine.TextObject)report.ReportDefinition.ReportObjects["txtNotes"]);
    txtNotes.Text = notes;
    report.SetParameterValue("@Quarter", Session["Quarter"].ToString());
    report.SetParameterValue("@Year", Session["Year"].ToString());
    report.SetParameterValue("@Campusid", Session["Campusid"].ToString());
    report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "FinancialAidInfo");

Open in new window

If I comment the three SetParameterValue lines out, the report will export, just with the data that was inputted into the "Main Report Preview" of the rpt file, but with those three lines passing the parameters, the error occurs at
report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "FinancialAidInfo");

Open in new window

Question by:FIM2003
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
LVL 18

Expert Comment

ID: 40022791
Looks like the session variable is not set

Author Comment

ID: 40022797
vasto: I was using this:

string strQtr = Session["Quarter"].ToString();
string strYr = Session["Year"].ToString();
string strCID = Session["Campusid"].ToString();
report.SetParameterValue("@Quarter", strQtr);
report.SetParameterValue("@Year", strYr);
report.SetParameterValue("@Campusid", strCID);

Open in new window

and went through checking the values with a breakpoint and all three variables have values.
LVL 44

Expert Comment

ID: 40022828
What is Response ?  Should that be set to something ?
report.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "FinancialAidInfo");
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.


Accepted Solution

FIM2003 earned 0 total points
ID: 40022883
I have resolved the problem. Had something to do with being able to access the report security wise. Adding this code before setting the parameter values fixed it:

foreach (CrystalDecisions.Shared.IConnectionInfo connection in report.DataSourceConnections)
    connection.IntegratedSecurity = true;

Open in new window


Author Closing Comment

ID: 40031579
This resolved the issue for me.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

722 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