Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Object reference not set to an instance of an object.

Status
Not open for further replies.

LinPro

Programmer
Jun 25, 2003
120
US
Hi All

I am getting this error when I try to run my cascading parameter report via Report Mangager and using aspx code.

If I use regular parameters, the report runs fine, but as soon as I add cascading parameters below is what I get.

__________________________________________________________
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:


Line 202: item.Value = validValue.Value
Line 203: lb.Items.Add(item)
Line 204: Next validValue
Line 205: 'If Page.IsPostBack = False Then
Line 206: 'lb.SelectedIndex = -1


Source File: D:\Inetpub\Sites\PHX-APCC-IOSNET\Shareportal\ApplicationModules\IOS\ReportServicesInvocationCascadingParameter.ascx.vb Line: 204
_________________________________________________________

Any idea what is needed in the aspx code that I need to do?

I am using Reporting Services, SQL Server 2000 and asp.net.


Thanks
LinPro
 
Hmm, I'd have to see more of your code. Have you tried running the report in Report Designer by itself first (no external application to pass the parameters)? If your report works fine there, then it might not be a Reporting Services problem and you can focus on the calling code.
 
unfortunately, that is the RS "generic error" message - it's like the 1004 runtime error in VBA - doesn't really tell you much....

Rgds, Geoff

Three things are certain. Death, taxes and lost data. DPlank is to blame

Please read FAQ222-2244 before you ask a question
 
Thanks

You both are right.

Yes, I did run the report in Report Manager and in Visual Studios already - and yes, in fact it runs perfectly .

I am sure it is the calling code. One thing I forgot to mention I am new to asp.net designing therefore any help would greatly appreciated.

Please let me know what other codes I should add so you can view what is happening.

Linpro
 
Try showing us the area of code that contains the error shown in your first post:

Source Error:

Line 202: item.Value = validValue.Value
Line 203: lb.Items.Add(item)
Line 204: Next validValue
Line 205: 'If Page.IsPostBack = False Then
Line 206: 'lb.SelectedIndex = -1
 
Ookete:
Sorry, I just got into work. Below is more of the codes.

thanks
Linpro



____________________________________________________________



Private Sub ExecReport(ByVal reportPath As String)

Dim forRendering As Boolean = True
Dim historyID As String = Nothing
Dim values As rs1.ParameterValue()
Dim credentials As rs1.DataSourceCredentials()
Dim rsUserID As String
Dim rsPassword As String
Dim rsDomain As String
Dim configurationAppSettings As System.Configuration.AppSettingsReader = New System.Configuration.AppSettingsReader

Try
report = reportPath
rsUserID = CType(configurationAppSettings.GetValue("RSUserID", GetType(System.String)), String)
rsPassword = CType(configurationAppSettings.GetValue("rsPassword", GetType(System.String)), String)
'rsDomain = CType(configurationAppSettings.GetValue("rsDomain", GetType(System.String)), String)

'rsUserID = "rsuser"
'rsPassword = "Password123"

reportingService.Credentials = New System.Net.NetworkCredential(rsUserID, rsPassword, rsDomain)
parameters = reportingService.GetReportParameters(report, historyID, forRendering, values, credentials)

If Not (parameters Is Nothing) Then

Dim strParameterTable As String

strParameterTable = "<TABLE class=""Normal"""
strParameterTable += " width=""99%"" border=""0"""
strParameterTable += " cellpadding=""4"" cellspacing=""0"""
strParameterTable += " align=""center"">"
strParameterTable += "<TR bgColor=#ffffff><TD width=""50%"">"
dynamicFieldsMarker.Controls.Add(New LiteralControl(strParameterTable))

Dim rp As rs1.ReportParameter
Dim i As Integer = 0
For Each rp In parameters
'If rp.Name <> "lob" Then
i = i + 1

'strParameterTable = "<DIV style=""PADDING-RIGHT: 2px; PADDING-LEFT: 2px; FLOAT: left; MARGIN-RIGHT: 2px; POSITION: static;"">"
strParameterTable += "<TABLE class=""Normal"""
strParameterTable += " border=""0"""
strParameterTable += " cellpadding=""0"" cellspacing=""0"""
strParameterTable += ">"
strParameterTable += "<THEAD><TR bgColor=#ffffff valign=""Bottom"">"
dynamicFieldsMarker.Controls.Add(New LiteralControl(strParameterTable))

Dim strParmPrompt As String
Dim strParmName As String
Dim ParmHasParent As Boolean
strParmPrompt = rp.Prompt
strParmName = rp.Name
If rp.Dependencies Is Nothing Then
ParmHasParent = False
Else
ParmHasParent = True
End If

dynamicFieldsMarker.Controls.Add(New LiteralControl("<TD nowrap bgColor=#ffffff class=""Normal"" valign=""Bottom""><font style=""FONT-WEIGHT: normal; FONT-SIZE: 10pt; COLOR: #003366; FONT-FAMILY: Arial"">" & strParmPrompt))
dynamicFieldsMarker.Controls.Add(New LiteralControl("</font></TD></TR></THEAD><TBODY><TR bgColor=#ffffff valign=""Top"">"))
dynamicFieldsMarker.Controls.Add(New LiteralControl("<TD align=""left""><BR>"))

If rp.Name = "Investment_id" Then
Dim tb As New System.Web.UI.WebControls.TextBox
tb.ID = rp.Name
dynamicFieldsMarker.Controls.Add(tb)

Else

Dim lb As New System.Web.UI.WebControls.ListBox
Dim strText As String

lb.SelectionMode = ListSelectionMode.Single
lb.Rows = 1
lb.ID = rp.Name
'If Not ParmHasParent Or Not Page.IsPostBack Then
If UCase(rp.Name) = "LOB" Then
Dim aData As DataSet
aData = GetValidLOBsbyUsername(GetSingleUserNameByID(Int32.Parse(context.User.Identity.Name)))
lb.DataSource = aData
lb.DataValueField = aData.Tables(0).Columns(0).ToString
lb.DataTextField = aData.Tables(0).Columns(1).ToString
'strText = aData.Tables(0).Columns(1).ToString & " (" & aData.Tables(0).Columns(0).ToString & ")"
'lb.DataTextField = strText
lb.DataBind()
ElseIf UCase(rp.Name) = "BU" Then
Dim aData As DataSet
aData = GetValidBUsbyUsername(GetSingleUserNameByID(Int32.Parse(context.User.Identity.Name)))
lb.DataSource = aData
lb.DataValueField = aData.Tables(0).Columns(0).ToString
lb.DataTextField = aData.Tables(0).Columns(1).ToString
'strText = aData.Tables(0).Columns(1).ToString & " (" & aData.Tables(0).Columns(0).ToString & ")"
'lb.DataTextField = strText
lb.DataBind()
Else
Dim validValue As rs1.ValidValue
For Each validValue In rp.ValidValues
Dim item As New System.Web.UI.WebControls.ListItem
item.Text = validValue.Label
item.Value = validValue.Value
lb.Items.Add(item)
Next validValue
'If Page.IsPostBack = False Then
'lb.SelectedIndex = -1
'End If
End If
'End If
lb.AutoPostBack = True
lb.EnableViewState = True
AddHandler lb.SelectedIndexChanged, AddressOf parameter_Click


dynamicFieldsMarker.Controls.Add(lb)
End If

dynamicFieldsMarker.Controls.Add(New LiteralControl("</TD></TR>"))
If i Mod 2 = 0 Then
dynamicFieldsMarker.Controls.Add(New LiteralControl("</TBODY></TABLE></TD></tr></table></TR><TR><TR bgColor=#ffffff><TD>"))
Else
dynamicFieldsMarker.Controls.Add(New LiteralControl("</TBODY></TABLE></TD></tr></table></td><td width=""50%"">"))
End If


Next rp

dynamicFieldsMarker.Controls.Add(New LiteralControl("</TD></TR></TBODY></TABLE>"))
dynamicFieldsMarker.Controls.Add(New LiteralControl(strParameterTable))

End If

Catch e As SoapException
Console.WriteLine(e.Detail.InnerXml.ToString())
End Try

End Sub
 
Well, there are some objects that are being used that I don't know anything about (rs1, for example). From the part of the code that is giving you the error message, I would perhaps make sure that rp.validvalues actually exists when you run it. Try debugging that area and make sure that everything is hooked up right when you step through it.

Sorry I can't tell you more than this. Good luck.
 
thanks, you are helping alot so far.

So far, validValues appears only in that section that I copied onto the email. If it appears in other parts of website, how do I check for that? Do I have to look in every aspx files?
 
If you are creating your code in Visual Studio, you should be able to do a search on every file to see if it's there. That would save you a little time as the computer would be doing all the looking and all you have to do is open each file, click on search and wait for the results.



Catadmin - MCDBA, MCSA
"If a person is Microsoft Certified, does that mean that Microsoft pays the bills for the funny white jackets that tie in the back???
 
thanks, I will try to see what I get. And get back with more info.
 
Hi Again

I found validValues in a couple of files. Two of the files are reference files setup by Reporting Services. Therefore, I am assuming that the validValues is binding to Reporting services parameters.

Now, the question is how do I set up the aspx code to use the validValues with cascading parameters from Reporting Services?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top