Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Using vb.net i have created a report backend as sql server, and in my main report i pass three parameters (2 date and 1 category id) and in sub report i have two parameters(2 date).

while i run the project i get some bug like the following,

Additional information: Object reference not set to an instance of an object.


What I have tried:

VB
''Main report parameters
Dim cryRpt As New ReportDocument
cryRpt.Load("report path")


            cryRpt.SetParameterValue("Exid", PrintId)
            cryRpt.SetParameterValue("Frm", FDate)
            cryRpt.SetParameterValue("To", TDate)

''Sub report parameters
            Dim mySubReport As ReportDocument
            mySubReport = cryRpt.OpenSubreport("report path")

            mySubReport.SetParameterValue("Frm", FDate)
            mySubReport.SetParameterValue("To", TDate)
Posted
Updated 10-Apr-17 4:28am
v2
Comments
CHill60 10-Apr-17 10:29am    
Debug your code. Determine if cryRpt is Nothing. If so then your report path is incorrect. If it is not nothing then check the value of mySubReport. If that is nothing then that "report path" is invalid.
jmavrix 10-Apr-17 10:39am    
Both the report are in the valid path, i am able to preview the report from vs2015.
but while i run the project i get error.is it mandatory to pass the same number of parameters in main report to sub report
CHill60 10-Apr-17 10:43am    
That is not the error you reported in your question!
jmavrix 10-Apr-17 10:55am    
error is the same , these are the thing which i have tried
CHill60 10-Apr-17 11:05am    
I've realised that was a question not an error message. I don't know how many parameters your reports need - I can't see them.
On exactly which line of code is this exception thrown?

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