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!

render method - report caching issue

Status
Not open for further replies.

jennyek2000

Programmer
Sep 2, 2003
43
GB
I am developing an ASP.NET web interface for the reporting services so that our reports can be used on our website for our clients.

I have a data-driven subscription set up to preload the cache for all of my reports. This works fine, and when I run any report via Report Manager or Report Server, it pulls the data from the cache as opposed to direct from the datasource.

However, when I call the Render method in ASP.NET with exactly the same parameters (I know this because I checked the executionLog in the database), the report data is regenerated. I am unable to see why this is happening. What is the difference between running the report from ReportServer or running Render from the ASP.NET page? Has anybody else had this problem? Thanks in advance


My code is as follows:


Dim rsReport As New wsReportServer.ReportingService

rsReport.Timeout = System.Threading.Timeout.Infinite

'Authenticate the web service client witht he report server by using the following

rsReport.Credentials = New System.Net.NetworkCredential(sUSERNAME, sPASSWORD, sDOMAIN)

Dim sEncoding As String = Nothing

Dim sMimeType As String = Nothing

Dim pParametersUsed As ParameterValue()Dim parameters() As ParameterValue



parameters = GetReportParameterValues()

Dim wWarnings As Warning()

Dim sStreamID As String

Dim sStreamIDS As String()



Try

btResult = rsReport.Render(m_sReportPath, sRenderFormat, Nothing, sDEVINFO, parameters, _

Nothing, Nothing, Nothing, Nothing, Nothing, wWarnings, sStreamIDS)

bReportRendered = True

Catch ex As Exception

If ex.Message.IndexOf("Object") >= 0 Then

Throw New Exception("This report is currently being modified - and requires activation")

Else

Throw ex

End If

bReportRendered = False

End Try

'All of the images

For Each sStreamID In sStreamIDS

Dim instance As HttpRequest

Try

btImage = rsReport.RenderStream(m_sReportPath, sHTML, sStreamID, Nothing, sDEVINFO, parameters, sEncoding, sMimeType)Dim stream As System.IO.FileStream = _

System.IO.File.OpenWrite(HttpContext.Current.Server.MapPath(".\Image\" & sStreamID))

stream.Write(btImage, 0, CInt(btImage.Length))

stream.Close()

Catch ex As Exception

Throw ex

End Try



Next

Else

'Throw an exception here

Throw New Exception("The report path has not been set")

End If

Catch ex As Exception

bReportRendered = False

Throw ex

End Try
 
In case anyone has a similar problem, I found the solution.

I had two additional parameters on this report, that I wanted to pass in NULL for. To do this, I was creating the parameter values to pass in ot the render method but ignoring the parameters whose values should by NULL. When I did setup the parameters but didnt pass in the values - it worked!

For example, for a report with two parameters - ParameterName, and NULLValueParameterName (where the latter has a value of NULL by default):

Dim parameters(0) AS ParameterValues

parameters(0) = New ParameterValue

parameters(0).Name = "ParameterName"

parameters(0).Value = "ParameterValue"

The correct way is:

Dim parameters(1) AS ParameterValues

parameters(0) = New ParameterValue

parameters(0).Name = "ParameterName"

parameters(0).Value = "ParameterValue"

parameters(1) = New ParameterValue

parameters(1).Name = "NULLValueParameterName"


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top