Saturday, February 25, 2012

Need urgent help, this is driving me crazy. SSRS 2000

Hi all,

I am trying to build a reportviewer so that I could use reporting services (due to company's security policy).

I am getting a VERY weird error here.

Before I get on ahead, here is the scenario.

I had created a rdl that will give a certain report based on two parameters. At the moment, I didn't assign the parameters to any default values since i don't want the report to start running. These two parameters are run based on stored procedures to get the starting date and an ending date.

I had tried to view this report on Report Manager and it works.

I had set the parameters this way. NOTE: ReportingServer is the disgused name of the reportserver I am using for privacy purposes

Code Snippet

Dim rs As New ReportingServer.ReportingService

rs.Credentials = System.Net.CredentialCache.DefaultCredentials

'Render arguments

Dim results() As Byte

Dim format As String = "HTML4.0"

Dim historyID As String = Nothing

'PDF Rendering extensions don't have any useful DeviceInfo settings

'the toolbar shown below only affects HTML rendering

Dim devInfo As String = "<DeviceInfo><HTMLFragment>True</HTMLFragment><JavaScript>True</JavaScript><Toolbar>True</Toolbar><Parameters>True</Parameters></DeviceInfo>"

Dim credentials() As ReportingServer.DataSourceCredentials = New ReportingServer.DataSourceCredentials() {}

Dim showHideToggle As String = ""

Dim encoding As String = ""

Dim mimeType As String = ""

Dim warnings() As ReportingServer.Warning = New ReportingServer.Warning(0) {}

Dim reportHistoryParameters() As ReportingServer.ParameterValue = New ReportingServer.ParameterValue() {}

Dim streamIDs() As String = Nothing

Dim sh As ReportingServer.SessionHeader = New ReportingServer.SessionHeader

rs.SessionHeaderValue = sh

But when I started building this reportviewer.aspx, it gives me this error on the following line:-

Code Snippet

results = rs.Render(ReportPath, format, historyID, devInfo, Parameters, credentials, _

showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)

with the error

{"This report requires a default or user-defined value for the report parameter 'start_date'. To run or subscribe to this report, you must provide a parameter value. --> This report requires a default or user-defined value for the report parameter 'start_date'. To run or subscribe to this report, you must provide a parameter value. --> This report requires a default or user-defined value for the report parameter 'start_date'. To run or subscribe to this report, you must provide a parameter value."}

this is occuring on the line where it needs to render the report.

As simple as it is, i tried the following:-

NOTE: some variables has been changed to protect some identity.

Code Snippet

Dim ReportRenderer As New RenderSQLReports

Dim Parameters As int.rrd.sqlreporting_test.ParameterValue() = Nothing

ReportRenderer.RenderReport(Parameters, "/Folder/reportname", "pdffilename.pdf")

What I don't get is that i made sure that it doesn't have any default values.

So I went into this scenario and tried teh following:-

Code Snippet

Dim ReportRenderer As New RenderSQLReports

Dim Parameters() As Reportingservices.ParameterValue = New Reportingservices.ParameterValue(1) {}

Parameters(0) = New Reportingservices.ParameterValue

Parameters(0).Label = "start_date"

Parameters(0).Name = "start_date"

Parameters(0).Value = "10/1/1999 12:00:00 AM"

Parameters(1) = New Reportingservices.ParameterValue

Parameters(1).Label = "end_date"

Parameters(1).Name = "end_date"

Parameters(1).Value = "11/1/1999 12:00:00 AM"

ReportRenderer.RenderReport(Parameters, "/Folder/reportname", "pdffilename.pdf")

And this is what happens. It blows up on this line again. with this error.

Code Snippet

results = rs.Render(ReportPath, format, historyID, devInfo, Parameters, credentials, _

showHideToggle, encoding, mimeType, reportHistoryParameters, warnings, streamIDs)

With the errors

{"Default value or value provided for the report parameter 'start_date' is not a valid value. --> Default value or value provided for the report parameter 'start_date' is not a valid value. --> Default value or value provided for the report parameter 'start_date' is not a valid value."}

This is probably occuring because the date I had provided is not found in the list of dates. I really don't want to default a date at the moment, to allow the user to select a date.

So I finally gave it a date...... a valid date.

Code Snippet

Dim ReportRenderer As New RenderSQLReports

Dim Parameters() As Reportingservices.ParameterValue = New Reportingservices.ParameterValue(1) {}

Parameters(0) = New Reportingservices.ParameterValue

Parameters(0).Label = "start_date"

Parameters(0).Name = "start_date"

Parameters(0).Value = "10/1/2004 12:00:00 AM"

Parameters(1) = New Reportingservices.ParameterValue

Parameters(1).Label = "end_date"

Parameters(1).Name = "end_date"

Parameters(1).Value = "11/1/2004 12:00:00 AM"

ReportRenderer.RenderReport(Parameters, "/Folder/reportname", "pdffilename.pdf")

LO and behold, it works BUT . now i get this error in the aspx code.

Runtime error has occured.


Microsoft JScript runtime error: 'Report' is undefined

on this weird line:- (that was generated automatically)

</script><script language="javascript" type="text/javascript" src="?rs:Command=Get&amp;rc:GetImage=8.00.1038.00Report.js">

</script><script language="javascript" type="text/javascript">

<!--

function OnLoadReport()

{

var pageHits = null;

var rep = new Report(1, 16, pageHits, false, docMapIds); <-where error is occuring.

if (parent != self) parent.OnLoadReport(rep);

}

//-->

</script>

It did show the report, but I don't understand why it is still getting an error here. Moreover, I didn't even get the HTMLViewer too even when I had assigned the devinfo....

Really need some help here, as this is quite urgent.... I am at a loss at this, and maybe that there is an option that I am not seeing or something I am missing. please help .

Bernard

-So close yet so far, How cruel are the software bugs-

alright ..

I am solving this bit by bit, but the most important is that I want to get the html report with the Toolbar and parameters to show.

So far I am setting up the default values at the moment, and so far it is rendering the report.

How do I show te Toolbar (HtmlVIEwer) and the Parameters section to show on html ?

I Tried the following in the Devinfo

Dim devInfo As String = "<DeviceInfo><Toolbar>True</Toolbar></DeviceInfo>"

And I got the following error in the Aspx code.
Microsoft JScript runtime error: 'Report' is undefined

on this weird line:- (that was generated automatically)

<script language="javascript" type="text/javascript" src="?rs:Command=Get&amp;rc:GetImage=8.00.1038.00Report.js">

</script><script language="javascript" type="text/javascript">

<!--

function OnLoadReport()

{

var pageHits = null;

var rep = new Report(1, 16, pageHits, false, docMapIds); <-where error is occuring.

if (parent != self) parent.OnLoadReport(rep);

}

//-->

</script>

if anybody could tell me what i need to do, that will be really useful and helpful.

Thanks !

Bernard

-So close yet so far, How cruel are the software bugs-

|||

Btong wrote:

alright ..

I am solving this bit by bit, but the most important is that I want to get the html report with the Toolbar and parameters to show.

So far I am setting up the default values at the moment, and so far it is rendering the report.

How do I show te Toolbar (HtmlVIEwer) and the Parameters section to show on html ?

I Tried the following in the Devinfo

Dim devInfo As String = "<DeviceInfo><Toolbar>True</Toolbar></DeviceInfo>"

And I got the following error in the Aspx code.
Microsoft JScript runtime error: 'Report' is undefined

on this weird line:- (that was generated automatically)

<script language="javascript" type="text/javascript" src="?rs:Command=Get&amp;rc:GetImage=8.00.1038.00Report.js">

</script><script language="javascript" type="text/javascript">

<!--

function OnLoadReport()

{

var pageHits = null;

var rep = new Report(1, 16, pageHits, false, docMapIds); <-where error is occuring.

if (parent != self) parent.OnLoadReport(rep);

}

//-->

</script>

if anybody could tell me what i need to do, that will be really useful and helpful.

Thanks !

Bernard

-So close yet so far, How cruel are the software bugs-

Alright Folks.

Got some good news, Managed to build my own HTMLViewer and ReportViewer with some available source code. I am able to set up the HTML for HTMLViewer and ReportViewer. However, in the course of doing so, I came across a very good question.

I had tried to set up the ASMX and use the property "Parameters" and "Toolbar" to set up the HTMLViewer but to no avail.

Setting "<Parameter>True</Parameter>" in the Devinfo string did not make the Parameters section appear in the HTML.

Setting "<Toolbar>True</Toolbar>" in the devinfo string caused a javascript error as described below:-

Microsoft JScript runtime error: 'Report' is undefined

this occured in :-

<script language="javascript" type="text/javascript" src="?rs:Command=Get&amp;rc:GetImage=8.00.1038.00Report.js">

</script><script language="javascript" type="text/javascript">

<!--

function OnLoadReport()

{

var pageHits = null;

var rep = new Report(1, 16, pageHits, false, docMapIds); <-where error is occuring.

if (parent != self) parent.OnLoadReport(rep);

}

//-->

</script>

If I set these parameters to false, My report does generate in html.

I am wondering whether is this a bug? if this is so, is there a hotfix for it ? Or am I missing something crucial at this point ?

Can someone confirm this ? Thanks !

Bernard

-So close yet so far, How cruel are the software bugs-

|||

hi All,

Just had a very interesting conversation with one of the SSRS coders/creators and I am very enlightened in this situation.

I had just confirmed the following:-

1) This is not a bug per say. It was never considered that the rendering the report through API will let you set up the PArameters or the toolbar section.

2) the devinfo is really use for the URL access for the reports.

3) If rendering the reports through API, you have to either set almost all properties to False OR set a null in the "<devinfo></devinfo>" in the devinfo string or it won't render. (getting the javascript error as described as above)

4) This devinfo only works if you are on the Report Manager page and won't work if you are trying to view the htmlviewer in another browser.

There are probably a lot of SSRS developers who may wonder "Why go through all the trouble trying to figure this out" OR "so what?"

Well I could see a couple of scenarios here.

1) Clients have full access to Report Manager. (hence the URL access)

2) Developers have to come up with some way to retrieve the parameters, render the report once. (this prevents the clients from accessing the report manager)

Now I could have gone through the second route, but I figured that maybe I could use the HTMLViewer option you would see in the Report Manager without having to expose the URL directly to the clients. (This is due to Company's policy, firewall issues as well as security issues and sensitive data issues).

I didn't want to build a dozen "middlemen" pages just to collect the parameters and then throw it to the rdl via asmx. (waste of time modifying all of them and really unsensible too).

In the end, I managed to build a class that will help in this situation. Not exposing the url directly when a user tries to view the source, and no one has to know where or what the url is, my ReportViewer page prevents that.

I thought that by using the devinfo through ASMX would provide some sort of Report Manager capability without exposing the direct URL.
No one has yet to ask if there is ever a fix that would allow the devinfo string to be utilized via ASMX (it seems that I was the first one to bring this up). So hopefully this may or may not provide some sort of closure to anyone who might be in the same situation as I am.

Thanks for reading this post !

No comments:

Post a Comment