September 21, 2010 at 10:22 am
I'm running reports built in Report Builder 2.0, stored in a folder at our Reporting Services 2005 Report Manager address (we recently changed to SQL 2008, and moved our reports to a new server, but the old address is still active as well).
In my Visual Studio solution, the old (SQL2000) RSService web reference has been replaced by the two SQL2005 references, RSS2005 (ReportService2005) and RSS2005Exe(ReportExecution2005). The current paths are specified properly in the webconfig file.
When a report is chosen, the folder is properly accessed, and the parameters are pulled which fill the parameters datagrid (using ReportServices2005's "GetReportParameters" method) on my Report Interface page. That all works fine:
Public Shared Function getParameters(ByVal reportPath As String) As Data.DataTable
rs.Credentials = networkCredential
rs.Url = _RSURL
Dim _historyID As String = Nothing
Dim _forRendering As Boolean = True
Dim _values As RSS2005.ParameterValue() = Nothing
Dim _credentials As RSS2005.DataSourceCredentials() = Nothing
Dim _parameters As RSS2005.ReportParameter() = Nothing
Dim pt As New Data.DataTable
Dim pr As Data.DataRow
Try
_parameters = rs.GetReportParameters(reportPath, _historyID, _forRendering, _values, _credentials)
If _parameters.Length > 0 Then
pt.Columns.Add("Name")
pt.Columns.Add("Prompt")
pt.Columns.Add("Value", GetType(Data.DataView))
Dim rp As RSS2005.ReportParameter
For Each rp In _parameters
If Not rp.Prompt = "" Then 'if the parameter is not hidden, add it to the lists
pr = pt.NewRow
pr("Name") = rp.Name.ToString
pr("Prompt") = rp.Prompt.ToString
'creates a datasource to populate the dropdownlist
Dim dvwDataSource As DataView
If Not rp.ValidValues Is Nothing Then
Dim table As New DataTable
Dim NewRow As DataRow
Dim colValue As DataColumn = New DataColumn("Value", Type.GetType("System.String"))
Dim colText As DataColumn = New DataColumn("Text", Type.GetType("System.String"))
table.Columns.Add(colValue)
table.Columns.Add(colText)
For i = 0 To rp.ValidValues.Length - 1
NewRow = table.NewRow()
NewRow("Value") = rp.ValidValues(i).Value
NewRow("Text") = rp.ValidValues(i).Label
table.Rows.Add(NewRow)
Next
table.AcceptChanges()
dvwDataSource = New DataView(table)
Else
dvwDataSource = New DataView()
End If
pr("Value") = dvwDataSource
pt.Rows.Add(pr)
End If
Next
End If
Catch ex As Exception
Throw ex
End Try
Return pt
End Function
...the above part is done in a class (ReptRender.vb) in the AppCode folder. In the Report Interface, a "LoadParameters" sub binds the returning list to dgParam, the datagrid which displays the parameters:
Protected Sub LoadParameters(ByVal ireportPath As String)
Dim dt As New DataTable
dt = ReptRender.getParameters(ireportPath)
dgParam.DataSource = dt
dgParam.DataBind()
End Sub
Here's the problem: when the "Render" button is clicked, the parameters are supposed to be pulled again, and the entered values sent off by the web service for report rendering. Unfortunately, when the parameters are retrieved for the Execute side, the GetReportParameters method suddenly looks in our OLD sql2000 Report Manager folder for the report!
Here's the render button click sub:
Private Sub btnRender_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRender.Click
Dim path As String = reportRoot + report
Dim format As String = ddFormat.SelectedValue
Dim historyID As String = Nothing
Dim parameters(0) As RSS2005Exe.ParameterValue
Dim encoding As String = String.Empty
Dim mimeType As String = String.Empty
Dim reportHistoryParameters As RSS2005Exe.ParameterValue() = Nothing
Dim warnings As RSS2005Exe.Warning() = Nothing
Dim streamIds As String() = Nothing
lblInfo.Text = String.Empty
' Prepare report parameters.
Dim i As Integer = 0
Dim visibleId As Integer = 0
Dim ddl As DropDownList = Nothing
Dim tx As TextBox = Nothing
Dim r_parameters As RSS2005.ReportParameter() = Nothing
rs.Credentials = networkCredential
r_parameters = rs.GetReportParameters(path, historyID, True, Nothing, Nothing)
ReDim parameters(r_parameters.Length - 1)
For Each rp In r_parameters
parameters(i) = New RSS2005Exe.ParameterValue
parameters(i).Name = rp.Name.ToString ' dgParam.Items(i).Cells(0).Text
If Not rp.Prompt = "" Then 'if the parameter is not hidden, add it to the lists
ddl = dgParam.Items(visibleId).FindControl("ddParam")
If Not ddl.Visible Then
tx = dgParam.Items(visibleId).FindControl("txParam")
parameters(i).Value = tx.Text
Else
parameters(i).Value = ddl.SelectedValue
End If
visibleId = visibleId + 1
End If
i = i + 1
Next
'......after some field validating (and passing of session values to hidden report parameters), we get to this:
If lblInfo.Text = String.Empty Then
mimeType = ReptRender.getMimeType(ddFormat.SelectedItem.Text)
Dim devInfo As String = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>"
Dim extension As String = ReptRender.GetExtension(mimeType)
Dim reportName As String = path.Substring(path.LastIndexOf("/") + 1)
Dim fileName As String = reportName & "." & extension
Dim idata As Byte()
Dim execInfo As New RSS2005Exe.ExecutionInfo
Dim execHeader As New RSS2005Exe.ExecutionHeader()
Dim SessionId As String
rsrv.Credentials = networkCredential
rsrv.Url = _RSURLExec
rsrv.ExecutionHeaderValue = execHeader
execInfo = rsrv.LoadReport(path, historyID)
rsrv.SetExecutionParameters(parameters, "en-us")
SessionId = rsrv.ExecutionHeaderValue.ExecutionID
idata = rsrv.Render(format, devInfo, extension, mimeType, encoding, warnings, streamIds)
'write the report back to the Response object
Response.Buffer = True
Response.BufferOutput = True
Response.ContentType = mimeType
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" & fileName)
Response.BinaryWrite(idata)
Response.End()
End If
End Sub
As soon as the code reaches this line:
r_parameters = rs.GetReportParameters(path, Nothing, True, Nothing, Nothing)
It breaks, giving me this error:
System.Web.Services.Protocols.SoapException: The item '/(my report path)' cannot be found. ---> Microsoft.ReportingServices.Diagnostics.Utilities.ItemNotFoundException: The item '/(my report path)' cannot be found.
--- End of inner exception stack trace ---
at Microsoft.ReportingServices.WebServer.ReportingService2005Impl.GetReportParameters(String Report, String HistoryID, Boolean ForRendering, ParameterValue[] Values, DataSourceCredentials[] Credentials, ReportParameter[]& Parameters)
at Microsoft.ReportingServices.WebServer.ReportingService2005.GetReportParameters(String Report, String HistoryID, Boolean ForRendering, ParameterValue[] Values, DataSourceCredentials[] Credentials, ReportParameter[]& Parameters)
Here's the weird thing: I first noticed the anomaly when I ran a report that existed in both the old and new versions of the same folder--it was breaking, saying that the entered parameter was the wrong data type. After digging into it, I noticed that the prompt on a parameter was spelled differently on execution ("region:" rather than "Region ID:"). I realized then what the problem is: when the web service gets the parameters on page load, it looks in the correct folder. But when it gets them on Execution, it's looking in our old sql2000 report manager folder!
Just to be sure, I renamed the folder containing the report. Since then, I've gotten the above error (it suddenly can't find the report because it's looking for a containing folder that no longer exists under that name on the old report manager).
As far as I can tell, the old address doesn't exist ANYWHERE in my application code. I've removed it from the web config file, and deleted the old Web Reference from the App Web References folder.
Both the ReportService2005 and ReportExecute2005 references have been updated.
I even looked in my IIS and application pool settings, searching for some other place where the reference might be configured.
Anybody else experienced this problem?
September 21, 2010 at 11:01 am
Solved it.
The problem was that even though I'd declared "rs" as an instance of Reporting Services 2005:
"Private rs As New ReportingService2005" and I'd also set up the right address in my web config, declaring "_RSURL" as the location:
"Private _RSURL As String = CType(_configurationAppSettings.GetValue("RSURL", GetType(String)), String)"
when the interface ran the rs.GetReportParameters routine in other places, it pointed at the correct address. For some reason (I still don't understand why), when it ran for the last time during the render button click event, it defaulted the URL of "rs" to our old Reports folder. So all I had to do was explicity remind the interface where to look right before it went to get render parameters.
After "Dim r_parameters As RSS2005.ReportParameter() = Nothing
rs.Credentials = networkCredential"
but before "r_parameters = rs.GetReportParameters(path, Nothing, True, Nothing, Nothing)"
I added "rs.Url = _RSURL"
Apparently, this was all it took to remind the web service where to look.
Still wish I could figure out why the application defaults the Reporting Service URL to an old address that seemingly doesn't exist in the code (sometimes I miss the old asp.net 1.1 days when you had to do more coding, but at least more of the under-the-hood stuff was accessible)!
Anyway, thanks for looking. Hope this helps somebody else.
Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy