Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have a problem with crystal report in VS 2008.
I can't display result of parameter' value.
when i run program, it must me enter parameter'value into textbox instead of show result. Then i click Input button, occur a error below:
Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
   CrystalDecisions.Reporting.WebControls.ParameterList.LoadPostData(String postDataKey, NameValueCollection postCollection) +443
   System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +343
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1743

But other website it is Ok.
My code:
rptDoc.Load(Server.MapPath("/Reports/Crystal/rptest.rpt"))
           rptDoc.SetParameterValue("@tuan1", "chào các bạn")
           rptDoc.SetDataSource(ds)
           rptViewer.ReportSource = rptDoc
Posted
Comments
[no name] 24-Jul-12 22:40pm    
So according to your code, it could only be a couple of things. Put a breakpoint in your method and see which one is null. Then make it not null and your error condition will go away.

1 solution

Object reference not set to an instance of an object

This error happens when you try to use a property or call a method of an object that is null. More details: here[^]

A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line. Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.


For now, looks like some issue while setting datasource.

Have a look at these articles on how to pass parameter to crystal report:
VB.NET Crystal Reports String parameter [^]
For passing parameter from TextBox to Crystal report Using vb.Net[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900