2012年2月16日星期四
BC30451 Name 'whatever' is not declared
group header, have a formula that shows that group's total as a % of
the grand total. Example:
Name Sales % of total
Tom 5 25%
Joe 15 75%
so, in my table, I have a table footer with a textbox "textbox1" with
the formula
=SUM(Fields!SALES.Value )
and in the group1 header, i have a textbox "textbox2". For the formula,
i put:
=Fields!SALES.Value / textbox1.value
This works in access, but apparently not in RS (?). I get an error
message that textbox1 is not declared. It seems like I must be missing
something simple here. Any Ideas? I could put subqueries in my dataset
I suppose, but that seems like an awfully long way around to do what I
need. Thanks in advance...
EricWill ReportItems!Textbox1.Value work?
Steve MunLeeuw
<c-eric.geil@.mci.com> wrote in message
news:1161292630.251749.186250@.k70g2000cwa.googlegroups.com...
> I'm migrating a report from access to RS. What I want to do is for each
> group header, have a formula that shows that group's total as a % of
> the grand total. Example:
> Name Sales % of total
> Tom 5 25%
> Joe 15 75%
> so, in my table, I have a table footer with a textbox "textbox1" with
> the formula
> =SUM(Fields!SALES.Value )
> and in the group1 header, i have a textbox "textbox2". For the formula,
> i put:
> =Fields!SALES.Value / textbox1.value
> This works in access, but apparently not in RS (?). I get an error
> message that textbox1 is not declared. It seems like I must be missing
> something simple here. Any Ideas? I could put subqueries in my dataset
> I suppose, but that seems like an awfully long way around to do what I
> need. Thanks in advance...
>
> Eric
>|||that worked...thanks!
What's the deal with the expression builder? It seems like it would
have some functions and/or controls listed in there to give the user
some clue as to their verbiage...
thanks again..
eric
Battling to programmatically load a report
I am struggling to programmatically render my report to a pdf without displaying it in a viewer and would appreciate a pointer in the right direction.
My code seems to work and the report is found and everything is honkey-dorey until I try to actually load the report.. lemme show: (please excuse the bit of a mess since this is just a test form)
rs = new rs2005.ReportingService2005();
rsExec = new rsExecService.ReportExecutionService();
// Prepare Render arguments
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
rsExecService.Warning[] warnings = null;
string[] streamIDs = null;
// Define variables needed for GetParameters() method
string _historyID = null;
bool _forRendering = false;
rs2005.ParameterValue[] _values = null;
// Authenticate to the Web service using Windows credentials
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs2005.DataSourceCredentials[] _credentials = null;
rs2005.ReportParameter[] _parameters = null;
FindReport();
//Create a variable containing the selected item
selItem = MyCatalogItem.Item;
try
{
// Get if any parameters needed.
_parameters = rs.GetReportParameters(selItem.Path , _historyID, _forRendering, _values, _credentials );
// Load the selected report.
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
// Prepare report parameter.
// Set the parameters for the report needed.
rsExecService.ParameterValue[] parameters = new rsExecService.ParameterValue[5];
// Place to include the parameter..
if (_parameters.Length > 0)
{
parameters[0] = new rsExecService.ParameterValue();
parameters[0].Value = pQuoteID.ToString();
parameters[0].Label = "Quote ID";
parameters[0].Name = "cor_Quote_id";
parameters[1] = new rsExecService.ParameterValue();
parameters[1].Value = DateTime.Now.ToString();
parameters[1].Label = "Quote Start Period";
parameters[1].Name = "QuoteStartPeriod";
parameters[2] = new rsExecService.ParameterValue();
parameters[2].Value = DateTime.Now.ToString();
parameters[2].Label = "Quote End Period";
parameters[2].Name = "QuoteEndPeriod";
parameters[3] = new rsExecService.ParameterValue();
parameters[3].Value = "Client";
parameters[3].Label = "Client";
parameters[3].Name = "ClientName";
parameters[4] = new rsExecService.ParameterValue();
parameters[4].Value = "Ralph Contact";
parameters[4].Label = "Ralph Contact";
parameters[4].Name = "RaljacContact";
}
rsExec.SetExecutionParameters(parameters, "en-us");
results = rsExec.Render(format, deviceInfo, out mimeType, out encoding, out warnings, out streamIDs);
// Create a file stream and write the report to it
using (FileStream stream = File.OpenWrite(fileName))
{
stream.Write(results, 0, results.Length);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Right, It bombs out at the section I marked in blue and gives me this HUGE message :
"System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/sqlserver/2005/01/12/reporting/reportingservices/LoadReport.\n at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()\n at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)\n at System.Web.Services.Protocols.SoapServerProtocol.Initialize()\n at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)"
Could this be related to credentials or something? Any advice welcome.
Thanks Mates
I remember using streams to do this many years ago (2004), but as I am a sloth, I have included this link for your perusal
http://www.codeproject.com/sqlrs/PDFUsingSQLRepServices.asp|||LOL It's a funny coincidence that you posted that link since I was working of that code to get my code to where it is. It's almost exactly the same except that my report doesn't load because of some sort of code or server setting problem I'm sure.
Thanks for the reply still. I appreciate it.
Regards
Mike
|||dumb question time....
you are using 2005, aren't you?|||Yes sir.
|||Can you prove that it is def using the 2005asmx and not the 2003asmx?
Am guessing the '2005' object at the top will automatically do this, but you never know.
I had a problem here with some users who had a soap header error and had to downgrade them to using the 2003 service. They were calling it from some java unix *** which couldn't seem to cope with the new definition.|||Maybe try setting the URL property of both web services. I had a similar issue before I did that.
rs.Url = "http://" & SERVER_NAME & "/ReportServer/ReportService2005.asmx?wsdl"
|||Ok I will try that and also make sure that and see what it comes up with.Thanks for the reply
|||Hi,
I tried setting the rs manually and it still gives me the same Error: server did not recognize the http soap header...
I wonder why it just seems to bomb out on the following line of code:
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
Regards
Mike
|||
Hey guys,
It would probably be a lot easier if you did this *without* SOAP. You can programmatically instantiate a reportviewer without showing it, btw. You will find instructions here... http://gotreportviewer.com/ (see Print a report from a console app -- you can render the thing to a PDF instead of page EMFs if you want the PDF instead of printing pages).
But you don't even need to do that. Here is an example I wrote for somebody else as part of a larger thing he was trying to solve. (Ignore the comments about package vars, he was doing this in SSIS). Basically the idea is to use URL access specifying a PDF in your case (see the comments about report parameters and URL querystring).
I think I should have used System.Net.WebRequest instead of the class I used in this code. But you might be using completely different classes in a completely different environment. This is straight HTTPRequest stuff, you can do it in javascript if you need to <g>.
|||Thanks Lisa,"Lisa Slater Nicholls" <lisa@.spacefold.com> wrote in message news:%23xdLwmwoHHA.4400@.TK2MSFTNGP03.phx.gbl...
OK, it wasn't that bad. And lucky you I've been kinda working on integrating SSIS with some reporting stuff anyway... so I was curious about how this would work...
Below is some sample script that you could use inside SSIS**. Just remember that, where I've hard-coded a sample report URL , you will actually be building it up based on package variables. And that includes your params.
** Caveat: it works as-is in SSIS except that I had to do something that looked really silly as an explicit cast, and I've included that as a comment because I'm not sure it's necessary.Notice how the URL includes a query string representing the path of the report and two options (in this case, rs:Command and rs:Format). These are arguments that belong to the report engine, and you can see it because of their rs: prefix. But if you had (say) a parameter for this report such as PopulationGreaterThan (the report in my example URL is based on a table of cities in the MySQL standard sample database), you could add this right onto the end of the URL:
&PopulationGreaterThan=50000
... got that? I give users URLs that include report params all the time... So, here's the code... Have fun.. >L<
' substitute the following line when working in SSIS
' for the instantiation of the HttpWebRequest object you see below:
' Dim ox As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create _
' ("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL"), HttpWebRequest)
Dim ox As System.Net.HttpWebRequest = _
System.Net.HttpWebRequest.Create _
("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL")'just substitute &rs:Format=PDF for &rs:format=EXCEL in the line above for a PDF
ox.UseDefaultCredentials = True' the line above may not work for you, you may have to provide credential information with more work
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Dim raw As System.IO.FileStream = New System.IO.FileStream("c:\temp\x.xls", IO.FileMode.Create)' for a PDF, change the extension in the line above, along with changing its
' name and folder based on (obviously!) more package vars
Dim buffer(1024) As Byte
Dim rs As System.IO.Stream = oy.GetResponseStream()
Dim read As Integer = rs.Read(buffer, 0, buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = rs.Read(buffer, 0, buffer.Length)
End While
oy.Close()
raw.Close()
raw.Dispose()
rs.Close()
rs.Dispose()
oy = Nothing
ox = Nothing
raw = Nothing
rs = Nothing
I'm definitely going to give this a bash.
Will report back soon.
Regards
Mike
|||
Well, it definitely works <rofl>. I'll take REST over SOAP, for anything like this, any day.
>L<
|||This code above works great for me as long as I don't attempt to add any report parameters to the querystring. To test the above code I created 2 reports:
report1 has no parameters
report2 has the parameter test
report1 runs fine:
http://localhost/reportserver/?/myreports/report1&rs:Command=Render&rs:format=EXCEL
report2 fails:
http://localhost/reportserver/?/myreports/report2&rs:Command=Render&rs:format=EXCEL&test=1
I get a 500 error at:
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Any ideas?
thanks!
|||Two things:
1) Remember I said it was better to use System.Net.WebRequest and System.Net.WebResponse (at least I think I remembered to say that when I reposted the example )? You really should... I don't think it's involved with your error, but do yourself a favor...
2) I definitely do this with parameters. However it is really easy to get it wrong, especially if you store the parts of the URL -- something may be escaping the "&", etc. I can't tell you exactly what is wrong with your requestURL but if you capture the URL you've built right before you do the WebRequest.Create(requestURL) you will probably see it. I have definitely seen that error when I screw this part up .
Below is an example from my code -- this is from inside an SSIS package, hence the DTS vars stuff. I know that the params are going through, because I can see the values in my results, but notice two interesting things: (a) I'm storing stuff separately, without including the ampersands in the values that I'm actually storing to package variables to avoid issues with their being escaped and (b) I'm using a kind of hokey trick to handle multiple params in one var rather than risking the ampersand there either.
3) Another thing that can give you the same error is if your deployed report doesn't actually have a parameter by that exact name <g>. So, did you just add that param into the designer, or did you remember to deploy it to the server? Sorry, but gotta ask...
HTH,
>L<
Code Snippet
requestURL = Dts.Variables("ExportRSURL").Value.ToString()
requestURL += "&rs:Command=Render"
requestURL += "&rs:Format=" & Dts.Variables("ExportRSType").Value.ToString()
If Len(Dts.Variables("ExportRSParams").Value.ToString()) > 0 Then
requestURL += "&" & Dts.Variables("ExportRSParams").Value.ToString().Replace("^", "&")
End If
|||Hi Lisa, once again, thank you for your input.This might be a really dumb question but your method is awesome but a little new to me (coming from the SOAP method)
I seem to be having problems with a report with more than 1 parameter where some of the parameters can be of a null value. How do I pass a null value through the request? (I tried useing cor_Quote_id=null&.....
but that didn't seem to work.
Report code
System.Net.WebRequest ox = System.Net.WebRequest.Create("http://localhost/reportserver/?/Raljac/rptQuote&cor_Quote_id=null&QuoteStartPeriod=2005\\01\\01&QuoteEndPeriod=2006\\01\\01&ClientName=ABC&RaljacContact=Rodney&rs:Command=Render&rs:format=PDF");
I get your method to work awesomely for reports with only 1 parm though
Regards
Battling to programmatically load a report
I am struggling to programmatically render my report to a pdf without displaying it in a viewer and would appreciate a pointer in the right direction.
My code seems to work and the report is found and everything is honkey-dorey until I try to actually load the report.. lemme show: (please excuse the bit of a mess since this is just a test form)
rs = new rs2005.ReportingService2005();
rsExec = new rsExecService.ReportExecutionService();
// Prepare Render arguments
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
rsExecService.Warning[] warnings = null;
string[] streamIDs = null;
// Define variables needed for GetParameters() method
string _historyID = null;
bool _forRendering = false;
rs2005.ParameterValue[] _values = null;
// Authenticate to the Web service using Windows credentials
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs2005.DataSourceCredentials[] _credentials = null;
rs2005.ReportParameter[] _parameters = null;
FindReport();
//Create a variable containing the selected item
selItem = MyCatalogItem.Item;
try
{
// Get if any parameters needed.
_parameters = rs.GetReportParameters(selItem.Path , _historyID, _forRendering, _values, _credentials );
// Load the selected report.
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
// Prepare report parameter.
// Set the parameters for the report needed.
rsExecService.ParameterValue[] parameters = new rsExecService.ParameterValue[5];
// Place to include the parameter..
if (_parameters.Length > 0)
{
parameters[0] = new rsExecService.ParameterValue();
parameters[0].Value = pQuoteID.ToString();
parameters[0].Label = "Quote ID";
parameters[0].Name = "cor_Quote_id";
parameters[1] = new rsExecService.ParameterValue();
parameters[1].Value = DateTime.Now.ToString();
parameters[1].Label = "Quote Start Period";
parameters[1].Name = "QuoteStartPeriod";
parameters[2] = new rsExecService.ParameterValue();
parameters[2].Value = DateTime.Now.ToString();
parameters[2].Label = "Quote End Period";
parameters[2].Name = "QuoteEndPeriod";
parameters[3] = new rsExecService.ParameterValue();
parameters[3].Value = "Client";
parameters[3].Label = "Client";
parameters[3].Name = "ClientName";
parameters[4] = new rsExecService.ParameterValue();
parameters[4].Value = "Ralph Contact";
parameters[4].Label = "Ralph Contact";
parameters[4].Name = "RaljacContact";
}
rsExec.SetExecutionParameters(parameters, "en-us");
results = rsExec.Render(format, deviceInfo, out mimeType, out encoding, out warnings, out streamIDs);
// Create a file stream and write the report to it
using (FileStream stream = File.OpenWrite(fileName))
{
stream.Write(results, 0, results.Length);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Right, It bombs out at the section I marked in blue and gives me this HUGE message :
"System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/sqlserver/2005/01/12/reporting/reportingservices/LoadReport.\n at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()\n at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)\n at System.Web.Services.Protocols.SoapServerProtocol.Initialize()\n at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)"
Could this be related to credentials or something? Any advice welcome.
Thanks Mates
I remember using streams to do this many years ago (2004), but as I am a sloth, I have included this link for your perusal
http://www.codeproject.com/sqlrs/PDFUsingSQLRepServices.asp|||LOL It's a funny coincidence that you posted that link since I was working of that code to get my code to where it is. It's almost exactly the same except that my report doesn't load because of some sort of code or server setting problem I'm sure.
Thanks for the reply still. I appreciate it.
Regards
Mike
|||dumb question time....
you are using 2005, aren't you?|||Yes sir.
|||Can you prove that it is def using the 2005asmx and not the 2003asmx?
Am guessing the '2005' object at the top will automatically do this, but you never know.
I had a problem here with some users who had a soap header error and had to downgrade them to using the 2003 service. They were calling it from some java unix *** which couldn't seem to cope with the new definition.|||Maybe try setting the URL property of both web services. I had a similar issue before I did that.
rs.Url = "http://" & SERVER_NAME & "/ReportServer/ReportService2005.asmx?wsdl"
|||Ok I will try that and also make sure that and see what it comes up with.Thanks for the reply
|||Hi,
I tried setting the rs manually and it still gives me the same Error: server did not recognize the http soap header...
I wonder why it just seems to bomb out on the following line of code:
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
Regards
Mike
|||
Hey guys,
It would probably be a lot easier if you did this *without* SOAP. You can programmatically instantiate a reportviewer without showing it, btw. You will find instructions here... http://gotreportviewer.com/ (see Print a report from a console app -- you can render the thing to a PDF instead of page EMFs if you want the PDF instead of printing pages).
But you don't even need to do that. Here is an example I wrote for somebody else as part of a larger thing he was trying to solve. (Ignore the comments about package vars, he was doing this in SSIS). Basically the idea is to use URL access specifying a PDF in your case (see the comments about report parameters and URL querystring).
I think I should have used System.Net.WebRequest instead of the class I used in this code. But you might be using completely different classes in a completely different environment. This is straight HTTPRequest stuff, you can do it in javascript if you need to <g>.
|||Thanks Lisa,"Lisa Slater Nicholls" <lisa@.spacefold.com> wrote in message news:%23xdLwmwoHHA.4400@.TK2MSFTNGP03.phx.gbl...
OK, it wasn't that bad. And lucky you I've been kinda working on integrating SSIS with some reporting stuff anyway... so I was curious about how this would work...
Below is some sample script that you could use inside SSIS**. Just remember that, where I've hard-coded a sample report URL , you will actually be building it up based on package variables. And that includes your params.
** Caveat: it works as-is in SSIS except that I had to do something that looked really silly as an explicit cast, and I've included that as a comment because I'm not sure it's necessary.Notice how the URL includes a query string representing the path of the report and two options (in this case, rs:Command and rs:Format). These are arguments that belong to the report engine, and you can see it because of their rs: prefix. But if you had (say) a parameter for this report such as PopulationGreaterThan (the report in my example URL is based on a table of cities in the MySQL standard sample database), you could add this right onto the end of the URL:
&PopulationGreaterThan=50000
... got that? I give users URLs that include report params all the time... So, here's the code... Have fun.. >L<
' substitute the following line when working in SSIS
' for the instantiation of the HttpWebRequest object you see below:
' Dim ox As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create _
' ("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL"), HttpWebRequest)
Dim ox As System.Net.HttpWebRequest = _
System.Net.HttpWebRequest.Create _
("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL")'just substitute &rs:Format=PDF for &rs:format=EXCEL in the line above for a PDF
ox.UseDefaultCredentials = True' the line above may not work for you, you may have to provide credential information with more work
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Dim raw As System.IO.FileStream = New System.IO.FileStream("c:\temp\x.xls", IO.FileMode.Create)' for a PDF, change the extension in the line above, along with changing its
' name and folder based on (obviously!) more package vars
Dim buffer(1024) As Byte
Dim rs As System.IO.Stream = oy.GetResponseStream()
Dim read As Integer = rs.Read(buffer, 0, buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = rs.Read(buffer, 0, buffer.Length)
End While
oy.Close()
raw.Close()
raw.Dispose()
rs.Close()
rs.Dispose()
oy = Nothing
ox = Nothing
raw = Nothing
rs = Nothing
I'm definitely going to give this a bash.
Will report back soon.
Regards
Mike
|||
Well, it definitely works <rofl>. I'll take REST over SOAP, for anything like this, any day.
>L<
|||This code above works great for me as long as I don't attempt to add any report parameters to the querystring. To test the above code I created 2 reports:
report1 has no parameters
report2 has the parameter test
report1 runs fine:
http://localhost/reportserver/?/myreports/report1&rs:Command=Render&rs:format=EXCEL
report2 fails:
http://localhost/reportserver/?/myreports/report2&rs:Command=Render&rs:format=EXCEL&test=1
I get a 500 error at:
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Any ideas?
thanks!
|||Two things:
1) Remember I said it was better to use System.Net.WebRequest and System.Net.WebResponse (at least I think I remembered to say that when I reposted the example )? You really should... I don't think it's involved with your error, but do yourself a favor...
2) I definitely do this with parameters. However it is really easy to get it wrong, especially if you store the parts of the URL -- something may be escaping the "&", etc. I can't tell you exactly what is wrong with your requestURL but if you capture the URL you've built right before you do the WebRequest.Create(requestURL) you will probably see it. I have definitely seen that error when I screw this part up .
Below is an example from my code -- this is from inside an SSIS package, hence the DTS vars stuff. I know that the params are going through, because I can see the values in my results, but notice two interesting things: (a) I'm storing stuff separately, without including the ampersands in the values that I'm actually storing to package variables to avoid issues with their being escaped and (b) I'm using a kind of hokey trick to handle multiple params in one var rather than risking the ampersand there either.
3) Another thing that can give you the same error is if your deployed report doesn't actually have a parameter by that exact name <g>. So, did you just add that param into the designer, or did you remember to deploy it to the server? Sorry, but gotta ask...
HTH,
>L<
Code Snippet
requestURL = Dts.Variables("ExportRSURL").Value.ToString()
requestURL += "&rs:Command=Render"
requestURL += "&rs:Format=" & Dts.Variables("ExportRSType").Value.ToString()
If Len(Dts.Variables("ExportRSParams").Value.ToString()) > 0 Then
requestURL += "&" & Dts.Variables("ExportRSParams").Value.ToString().Replace("^", "&")
End If
|||Hi Lisa, once again, thank you for your input.This might be a really dumb question but your method is awesome but a little new to me (coming from the SOAP method)
I seem to be having problems with a report with more than 1 parameter where some of the parameters can be of a null value. How do I pass a null value through the request? (I tried useing cor_Quote_id=null&.....
but that didn't seem to work.
Report code
System.Net.WebRequest ox = System.Net.WebRequest.Create("http://localhost/reportserver/?/Raljac/rptQuote&cor_Quote_id=null&QuoteStartPeriod=2005\\01\\01&QuoteEndPeriod=2006\\01\\01&ClientName=ABC&RaljacContact=Rodney&rs:Command=Render&rs:format=PDF");
I get your method to work awesomely for reports with only 1 parm though
Regards
Battling to programmatically load a report
I am struggling to programmatically render my report to a pdf without displaying it in a viewer and would appreciate a pointer in the right direction.
My code seems to work and the report is found and everything is honkey-dorey until I try to actually load the report.. lemme show: (please excuse the bit of a mess since this is just a test form)
rs = new rs2005.ReportingService2005();
rsExec = new rsExecService.ReportExecutionService();
// Prepare Render arguments
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
rsExecService.Warning[] warnings = null;
string[] streamIDs = null;
// Define variables needed for GetParameters() method
string _historyID = null;
bool _forRendering = false;
rs2005.ParameterValue[] _values = null;
// Authenticate to the Web service using Windows credentials
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs2005.DataSourceCredentials[] _credentials = null;
rs2005.ReportParameter[] _parameters = null;
FindReport();
//Create a variable containing the selected item
selItem = MyCatalogItem.Item;
try
{
// Get if any parameters needed.
_parameters = rs.GetReportParameters(selItem.Path , _historyID, _forRendering, _values, _credentials );
// Load the selected report.
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
// Prepare report parameter.
// Set the parameters for the report needed.
rsExecService.ParameterValue[] parameters = new rsExecService.ParameterValue[5];
// Place to include the parameter..
if (_parameters.Length > 0)
{
parameters[0] = new rsExecService.ParameterValue();
parameters[0].Value = pQuoteID.ToString();
parameters[0].Label = "Quote ID";
parameters[0].Name = "cor_Quote_id";
parameters[1] = new rsExecService.ParameterValue();
parameters[1].Value = DateTime.Now.ToString();
parameters[1].Label = "Quote Start Period";
parameters[1].Name = "QuoteStartPeriod";
parameters[2] = new rsExecService.ParameterValue();
parameters[2].Value = DateTime.Now.ToString();
parameters[2].Label = "Quote End Period";
parameters[2].Name = "QuoteEndPeriod";
parameters[3] = new rsExecService.ParameterValue();
parameters[3].Value = "Client";
parameters[3].Label = "Client";
parameters[3].Name = "ClientName";
parameters[4] = new rsExecService.ParameterValue();
parameters[4].Value = "Ralph Contact";
parameters[4].Label = "Ralph Contact";
parameters[4].Name = "RaljacContact";
}
rsExec.SetExecutionParameters(parameters, "en-us");
results = rsExec.Render(format, deviceInfo, out mimeType, out encoding, out warnings, out streamIDs);
// Create a file stream and write the report to it
using (FileStream stream = File.OpenWrite(fileName))
{
stream.Write(results, 0, results.Length);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Right, It bombs out at the section I marked in blue and gives me this HUGE message :
"System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/sqlserver/2005/01/12/reporting/reportingservices/LoadReport.\n at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()\n at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)\n at System.Web.Services.Protocols.SoapServerProtocol.Initialize()\n at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)"
Could this be related to credentials or something? Any advice welcome.
Thanks Mates
I remember using streams to do this many years ago (2004), but as I am a sloth, I have included this link for your perusal
http://www.codeproject.com/sqlrs/PDFUsingSQLRepServices.asp|||LOL It's a funny coincidence that you posted that link since I was working of that code to get my code to where it is. It's almost exactly the same except that my report doesn't load because of some sort of code or server setting problem I'm sure.
Thanks for the reply still. I appreciate it.
Regards
Mike
|||dumb question time....
you are using 2005, aren't you?|||Yes sir.
|||Can you prove that it is def using the 2005asmx and not the 2003asmx?
Am guessing the '2005' object at the top will automatically do this, but you never know.
I had a problem here with some users who had a soap header error and had to downgrade them to using the 2003 service. They were calling it from some java unix *** which couldn't seem to cope with the new definition.|||Maybe try setting the URL property of both web services. I had a similar issue before I did that.
rs.Url = "http://" & SERVER_NAME & "/ReportServer/ReportService2005.asmx?wsdl"
|||Ok I will try that and also make sure that and see what it comes up with.Thanks for the reply
|||Hi,
I tried setting the rs manually and it still gives me the same Error: server did not recognize the http soap header...
I wonder why it just seems to bomb out on the following line of code:
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
Regards
Mike
|||
Hey guys,
It would probably be a lot easier if you did this *without* SOAP. You can programmatically instantiate a reportviewer without showing it, btw. You will find instructions here... http://gotreportviewer.com/ (see Print a report from a console app -- you can render the thing to a PDF instead of page EMFs if you want the PDF instead of printing pages).
But you don't even need to do that. Here is an example I wrote for somebody else as part of a larger thing he was trying to solve. (Ignore the comments about package vars, he was doing this in SSIS). Basically the idea is to use URL access specifying a PDF in your case (see the comments about report parameters and URL querystring).
I think I should have used System.Net.WebRequest instead of the class I used in this code. But you might be using completely different classes in a completely different environment. This is straight HTTPRequest stuff, you can do it in javascript if you need to <g>.
|||Thanks Lisa,"Lisa Slater Nicholls" <lisa@.spacefold.com> wrote in message news:%23xdLwmwoHHA.4400@.TK2MSFTNGP03.phx.gbl...
OK, it wasn't that bad. And lucky you I've been kinda working on integrating SSIS with some reporting stuff anyway... so I was curious about how this would work...
Below is some sample script that you could use inside SSIS**. Just remember that, where I've hard-coded a sample report URL , you will actually be building it up based on package variables. And that includes your params.
** Caveat: it works as-is in SSIS except that I had to do something that looked really silly as an explicit cast, and I've included that as a comment because I'm not sure it's necessary.Notice how the URL includes a query string representing the path of the report and two options (in this case, rs:Command and rs:Format). These are arguments that belong to the report engine, and you can see it because of their rs: prefix. But if you had (say) a parameter for this report such as PopulationGreaterThan (the report in my example URL is based on a table of cities in the MySQL standard sample database), you could add this right onto the end of the URL:
&PopulationGreaterThan=50000
... got that? I give users URLs that include report params all the time... So, here's the code... Have fun.. >L<
' substitute the following line when working in SSIS
' for the instantiation of the HttpWebRequest object you see below:
' Dim ox As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create _
' ("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL"), HttpWebRequest)
Dim ox As System.Net.HttpWebRequest = _
System.Net.HttpWebRequest.Create _
("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL")'just substitute &rs:Format=PDF for &rs:format=EXCEL in the line above for a PDF
ox.UseDefaultCredentials = True' the line above may not work for you, you may have to provide credential information with more work
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Dim raw As System.IO.FileStream = New System.IO.FileStream("c:\temp\x.xls", IO.FileMode.Create)' for a PDF, change the extension in the line above, along with changing its
' name and folder based on (obviously!) more package vars
Dim buffer(1024) AsByte
Dim rs As System.IO.Stream = oy.GetResponseStream()
Dim read AsInteger = rs.Read(buffer, 0, buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = rs.Read(buffer, 0, buffer.Length)
EndWhile
oy.Close()
raw.Close()
raw.Dispose()
rs.Close()
rs.Dispose()
oy = Nothing
ox = Nothing
raw = Nothing
rs = Nothing
I'm definitely going to give this a bash.
Will report back soon.
Regards
Mike
|||
Well, it definitely works <rofl>. I'll take REST over SOAP, for anything like this, any day.
>L<
|||This code above works great for me as long as I don't attempt to add any report parameters to the querystring. To test the above code I created 2 reports:
report1 has no parameters
report2 has the parameter test
report1 runs fine:
http://localhost/reportserver/?/myreports/report1&rs:Command=Render&rs:format=EXCEL
report2 fails:
http://localhost/reportserver/?/myreports/report2&rs:Command=Render&rs:format=EXCEL&test=1
I get a 500 error at:
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Any ideas?
thanks!
|||Two things:
1) Remember I said it was better to use System.Net.WebRequest and System.Net.WebResponse (at least I think I remembered to say that when I reposted the example )? You really should... I don't think it's involved with your error, but do yourself a favor...
2) I definitely do this with parameters. However it is really easy to get it wrong, especially if you store the parts of the URL -- something may be escaping the "&", etc. I can't tell you exactly what is wrong with your requestURL but if you capture the URL you've built right before you do the WebRequest.Create(requestURL) you will probably see it. I have definitely seen that error when I screw this part up .
Below is an example from my code -- this is from inside an SSIS package, hence the DTS vars stuff. I know that the params are going through, because I can see the values in my results, but notice two interesting things: (a) I'm storing stuff separately, without including the ampersands in the values that I'm actually storing to package variables to avoid issues with their being escaped and (b) I'm using a kind of hokey trick to handle multiple params in one var rather than risking the ampersand there either.
3) Another thing that can give you the same error is if your deployed report doesn't actually have a parameter by that exact name <g>. So, did you just add that param into the designer, or did you remember to deploy it to the server? Sorry, but gotta ask...
HTH,
>L<
Code Snippet
requestURL = Dts.Variables("ExportRSURL").Value.ToString()
requestURL += "&rs:Command=Render"
requestURL += "&rs:Format=" & Dts.Variables("ExportRSType").Value.ToString()
If Len(Dts.Variables("ExportRSParams").Value.ToString()) > 0 Then
requestURL += "&" & Dts.Variables("ExportRSParams").Value.ToString().Replace("^", "&")
EndIf
|||Hi Lisa, once again, thank you for your input.This might be a really dumb question but your method is awesome but a little new to me (coming from the SOAP method)
I seem to be having problems with a report with more than 1 parameter where some of the parameters can be of a null value. How do I pass a null value through the request? (I tried useing cor_Quote_id=null&.....
but that didn't seem to work.
Report code
System.Net.WebRequest ox = System.Net.WebRequest.Create("http://localhost/reportserver/?/Raljac/rptQuote&cor_Quote_id=null&QuoteStartPeriod=2005\\01\\01&QuoteEndPeriod=2006\\01\\01&ClientName=ABC&RaljacContact=Rodney&rs:Command=Render&rs:format=PDF");
I get your method to work awesomely for reports with only 1 parm though
Regards
Battling to programmatically load a report
I am struggling to programmatically render my report to a pdf without displaying it in a viewer and would appreciate a pointer in the right direction.
My code seems to work and the report is found and everything is honkey-dorey until I try to actually load the report.. lemme show: (please excuse the bit of a mess since this is just a test form)
rs = new rs2005.ReportingService2005();
rsExec = new rsExecService.ReportExecutionService();
// Prepare Render arguments
string historyID = null;
string deviceInfo = null;
string format = "PDF";
Byte[] results;
string encoding = String.Empty;
string mimeType = String.Empty;
string extension = String.Empty;
rsExecService.Warning[] warnings = null;
string[] streamIDs = null;
// Define variables needed for GetParameters() method
string _historyID = null;
bool _forRendering = false;
rs2005.ParameterValue[] _values = null;
// Authenticate to the Web service using Windows credentials
rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
rsExec.Credentials = System.Net.CredentialCache.DefaultCredentials;
rs2005.DataSourceCredentials[] _credentials = null;
rs2005.ReportParameter[] _parameters = null;
FindReport();
//Create a variable containing the selected item
selItem = MyCatalogItem.Item;
try
{
// Get if any parameters needed.
_parameters = rs.GetReportParameters(selItem.Path , _historyID, _forRendering, _values, _credentials );
// Load the selected report.
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
// Prepare report parameter.
// Set the parameters for the report needed.
rsExecService.ParameterValue[] parameters = new rsExecService.ParameterValue[5];
// Place to include the parameter..
if (_parameters.Length > 0)
{
parameters[0] = new rsExecService.ParameterValue();
parameters[0].Value = pQuoteID.ToString();
parameters[0].Label = "Quote ID";
parameters[0].Name = "cor_Quote_id";
parameters[1] = new rsExecService.ParameterValue();
parameters[1].Value = DateTime.Now.ToString();
parameters[1].Label = "Quote Start Period";
parameters[1].Name = "QuoteStartPeriod";
parameters[2] = new rsExecService.ParameterValue();
parameters[2].Value = DateTime.Now.ToString();
parameters[2].Label = "Quote End Period";
parameters[2].Name = "QuoteEndPeriod";
parameters[3] = new rsExecService.ParameterValue();
parameters[3].Value = "Client";
parameters[3].Label = "Client";
parameters[3].Name = "ClientName";
parameters[4] = new rsExecService.ParameterValue();
parameters[4].Value = "Ralph Contact";
parameters[4].Label = "Ralph Contact";
parameters[4].Name = "RaljacContact";
}
rsExec.SetExecutionParameters(parameters, "en-us");
results = rsExec.Render(format, deviceInfo, out mimeType, out encoding, out warnings, out streamIDs);
// Create a file stream and write the report to it
using (FileStream stream = File.OpenWrite(fileName))
{
stream.Write(results, 0, results.Length);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Right, It bombs out at the section I marked in blue and gives me this HUGE message :
"System.Web.Services.Protocols.SoapException: Server did not recognize the value of HTTP Header SOAPAction: http://schemas.microsoft.com/sqlserver/2005/01/12/reporting/reportingservices/LoadReport.\n at System.Web.Services.Protocols.Soap11ServerProtocolHelper.RouteRequest()\n at System.Web.Services.Protocols.SoapServerProtocol.RouteRequest(SoapServerMessage message)\n at System.Web.Services.Protocols.SoapServerProtocol.Initialize()\n at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)"
Could this be related to credentials or something? Any advice welcome.
Thanks Mates
I remember using streams to do this many years ago (2004), but as I am a sloth, I have included this link for your perusal
http://www.codeproject.com/sqlrs/PDFUsingSQLRepServices.asp|||LOL It's a funny coincidence that you posted that link since I was working of that code to get my code to where it is. It's almost exactly the same except that my report doesn't load because of some sort of code or server setting problem I'm sure.
Thanks for the reply still. I appreciate it.
Regards
Mike
|||dumb question time....
you are using 2005, aren't you?|||Yes sir.
|||Can you prove that it is def using the 2005asmx and not the 2003asmx?
Am guessing the '2005' object at the top will automatically do this, but you never know.
I had a problem here with some users who had a soap header error and had to downgrade them to using the 2003 service. They were calling it from some java unix *** which couldn't seem to cope with the new definition.|||Maybe try setting the URL property of both web services. I had a similar issue before I did that.
rs.Url = "http://" & SERVER_NAME & "/ReportServer/ReportService2005.asmx?wsdl"
|||Ok I will try that and also make sure that and see what it comes up with.Thanks for the reply
|||Hi,
I tried setting the rs manually and it still gives me the same Error: server did not recognize the http soap header...
I wonder why it just seems to bomb out on the following line of code:
rsExecService.ExecutionInfo ei = rsExec.LoadReport(selItem.Path, historyID);
Regards
Mike
|||
Hey guys,
It would probably be a lot easier if you did this *without* SOAP. You can programmatically instantiate a reportviewer without showing it, btw. You will find instructions here... http://gotreportviewer.com/ (see Print a report from a console app -- you can render the thing to a PDF instead of page EMFs if you want the PDF instead of printing pages).
But you don't even need to do that. Here is an example I wrote for somebody else as part of a larger thing he was trying to solve. (Ignore the comments about package vars, he was doing this in SSIS). Basically the idea is to use URL access specifying a PDF in your case (see the comments about report parameters and URL querystring).
I think I should have used System.Net.WebRequest instead of the class I used in this code. But you might be using completely different classes in a completely different environment. This is straight HTTPRequest stuff, you can do it in javascript if you need to <g>.
|||Thanks Lisa,"Lisa Slater Nicholls" <lisa@.spacefold.com> wrote in message news:%23xdLwmwoHHA.4400@.TK2MSFTNGP03.phx.gbl...
OK, it wasn't that bad. And lucky you I've been kinda working on integrating SSIS with some reporting stuff anyway... so I was curious about how this would work...
Below is some sample script that you could use inside SSIS**. Just remember that, where I've hard-coded a sample report URL , you will actually be building it up based on package variables. And that includes your params.
** Caveat: it works as-is in SSIS except that I had to do something that looked really silly as an explicit cast, and I've included that as a comment because I'm not sure it's necessary.Notice how the URL includes a query string representing the path of the report and two options (in this case, rs:Command and rs:Format). These are arguments that belong to the report engine, and you can see it because of their rs: prefix. But if you had (say) a parameter for this report such as PopulationGreaterThan (the report in my example URL is based on a table of cities in the MySQL standard sample database), you could add this right onto the end of the URL:
&PopulationGreaterThan=50000
... got that? I give users URLs that include report params all the time... So, here's the code... Have fun.. >L<
' substitute the following line when working in SSIS
' for the instantiation of the HttpWebRequest object you see below:
' Dim ox As System.Net.HttpWebRequest = CType(System.Net.HttpWebRequest.Create _
' ("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL"), HttpWebRequest)
Dim ox As System.Net.HttpWebRequest = _
System.Net.HttpWebRequest.Create _
("http://localhost/reportserver/?/Report+Project1/TestCity&rs:Command=Render&rs:format=EXCEL")'just substitute &rs:Format=PDF for &rs:format=EXCEL in the line above for a PDF
ox.UseDefaultCredentials = True' the line above may not work for you, you may have to provide credential information with more work
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Dim raw As System.IO.FileStream = New System.IO.FileStream("c:\temp\x.xls", IO.FileMode.Create)' for a PDF, change the extension in the line above, along with changing its
' name and folder based on (obviously!) more package vars
Dim buffer(1024) As Byte
Dim rs As System.IO.Stream = oy.GetResponseStream()
Dim read As Integer = rs.Read(buffer, 0, buffer.Length)
While (read > 0)
raw.Write(buffer, 0, read)
read = rs.Read(buffer, 0, buffer.Length)
End While
oy.Close()
raw.Close()
raw.Dispose()
rs.Close()
rs.Dispose()
oy = Nothing
ox = Nothing
raw = Nothing
rs = Nothing
I'm definitely going to give this a bash.
Will report back soon.
Regards
Mike
|||
Well, it definitely works <rofl>. I'll take REST over SOAP, for anything like this, any day.
>L<
|||This code above works great for me as long as I don't attempt to add any report parameters to the querystring. To test the above code I created 2 reports:
report1 has no parameters
report2 has the parameter test
report1 runs fine:
http://localhost/reportserver/?/myreports/report1&rs:Command=Render&rs:format=EXCEL
report2 fails:
http://localhost/reportserver/?/myreports/report2&rs:Command=Render&rs:format=EXCEL&test=1
I get a 500 error at:
Dim oy As System.Net.HttpWebResponse = ox.GetResponse()
Any ideas?
thanks!
|||Two things:
1) Remember I said it was better to use System.Net.WebRequest and System.Net.WebResponse (at least I think I remembered to say that when I reposted the example )? You really should... I don't think it's involved with your error, but do yourself a favor...
2) I definitely do this with parameters. However it is really easy to get it wrong, especially if you store the parts of the URL -- something may be escaping the "&", etc. I can't tell you exactly what is wrong with your requestURL but if you capture the URL you've built right before you do the WebRequest.Create(requestURL) you will probably see it. I have definitely seen that error when I screw this part up .
Below is an example from my code -- this is from inside an SSIS package, hence the DTS vars stuff. I know that the params are going through, because I can see the values in my results, but notice two interesting things: (a) I'm storing stuff separately, without including the ampersands in the values that I'm actually storing to package variables to avoid issues with their being escaped and (b) I'm using a kind of hokey trick to handle multiple params in one var rather than risking the ampersand there either.
3) Another thing that can give you the same error is if your deployed report doesn't actually have a parameter by that exact name <g>. So, did you just add that param into the designer, or did you remember to deploy it to the server? Sorry, but gotta ask...
HTH,
>L<
Code Snippet
requestURL = Dts.Variables("ExportRSURL").Value.ToString()
requestURL += "&rs:Command=Render"
requestURL += "&rs:Format=" & Dts.Variables("ExportRSType").Value.ToString()
If Len(Dts.Variables("ExportRSParams").Value.ToString()) > 0 Then
requestURL += "&" & Dts.Variables("ExportRSParams").Value.ToString().Replace("^", "&")
End If
|||Hi Lisa, once again, thank you for your input.This might be a really dumb question but your method is awesome but a little new to me (coming from the SOAP method)
I seem to be having problems with a report with more than 1 parameter where some of the parameters can be of a null value. How do I pass a null value through the request? (I tried useing cor_Quote_id=null&.....
but that didn't seem to work.
Report code
System.Net.WebRequest ox = System.Net.WebRequest.Create("http://localhost/reportserver/?/Raljac/rptQuote&cor_Quote_id=null&QuoteStartPeriod=2005\\01\\01&QuoteEndPeriod=2006\\01\\01&ClientName=ABC&RaljacContact=Rodney&rs:Command=Render&rs:format=PDF");
I get your method to work awesomely for reports with only 1 parm though
Regards
2012年2月13日星期一
Batch Printing
I have a customer report that I need to automatically print at the end of
each month. What is the best way to programmatically print the report? Is
it also possible to specify the customers so that the report gets printed for
say all customers with a transaction in the last 30 days?
ThanksHi David,
Try adding a subscription to a file system for a report which prints all
statements and then have a windows scheduled job which pick up the PDF and
automatically print it. There are a number of windows script files which will
print all PDF's in a directory.
"David" wrote:
> Hi All
> I have a customer report that I need to automatically print at the end of
> each month. What is the best way to programmatically print the report? Is
> it also possible to specify the customers so that the report gets printed for
> say all customers with a transaction in the last 30 days?
> Thanks|||I've set up subscriptions but I have to go into the server and manually print
the PDF files. I'm being told by my vendor that I have to purchase a
supplemental program that costs 13K in order to print them automatically.
Isn't there an easier way?
"Jeremy Bentvelzen" wrote:
> Hi David,
> Try adding a subscription to a file system for a report which prints all
> statements and then have a windows scheduled job which pick up the PDF and
> automatically print it. There are a number of windows script files which will
> print all PDF's in a directory.
> "David" wrote:
> > Hi All
> >
> > I have a customer report that I need to automatically print at the end of
> > each month. What is the best way to programmatically print the report? Is
> > it also possible to specify the customers so that the report gets printed for
> > say all customers with a transaction in the last 30 days?
> >
> > Thanks
Batch Printing
are 296 choices for Parm1. Is there anyway to create a batch job to run
this report for all 296 choices and send to .PDF?You could create a data driven subscription that could accomplished
this, although that may be a bit of work. Is the requirement to have
seperate PDF's for all 296? A document map would allow easy navigation
to the 296 different parm values inside one report, and document maps
export over to PDF's.
Matt A
www.reportarchitex.com
Batch Execution of Reports
the user is accessing each one (via a URL with the appropriate PDF rendering
tags) from a custom web application to generate the reports. What they'd
really prefer to do is click one "button" or something that executes all of
the reports at once, but still creates a separate PDF output for each (and I
don't want to append the report files into one big master report file). I'm
not sure how to go about this since a user can't "batch" click on a set of
URLs to get the reports. Are there any suggestions or resources that I
could refer to on how to best accomplish this?
-marcLook at the BOL. You can batch run your reports via a VB.NET script.
I am not a scripting kinda guy, so I ill have to defer you to look
elsewhere for specifics on scripting.
RS.EXE is the commandline utility for Reporting Services.
"Marc" <marc@.machin.com> wrote in message news:<eHYf8bEzEHA.2788@.TK2MSFTNGP15.phx.gbl>...
> I have a report server set up with about a dozen or so reports. Right now,
> the user is accessing each one (via a URL with the appropriate PDF rendering
> tags) from a custom web application to generate the reports. What they'd
> really prefer to do is click one "button" or something that executes all of
> the reports at once, but still creates a separate PDF output for each (and I
> don't want to append the report files into one big master report file). I'm
> not sure how to go about this since a user can't "batch" click on a set of
> URLs to get the reports. Are there any suggestions or resources that I
> could refer to on how to best accomplish this?
> -marc
2012年2月12日星期日
Basing Report on a Procedure with Cursor
I need some advice on how to design a report using cursors.
Is it possible to base a report on a cursor?
I would think that I would have to put the cursor into a stored procedure and call that procedure. But if I do use the cursor in the procedure, will the looped variables automatically populate the report or will I need to insert them into a table that populates the report?
Thanks,
cj
If the data source type is "Oracle" and you want to call a Oracle stored procedure, please search for related threads on this forum regarding Oracle stored procedures (e.g. http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=356162&SiteID=1).
-- Robert
|||No, it is SQL Server.|||This should work just fine if you follow the guidelines in http://msdn2.microsoft.com/en-us/library/ms159260.aspx - scroll to the stored procedure section.
If you experience problems, can you post a sample of a SQL stored procedure that doesn't work?
-- Robert
|||Thanks, I understand that part now. Usually I am populating a table to get my output from the stored procedure. For example, I'll use the INSERT clause to populate as the cursor loops. Can I populate the dataset instead? If so, how?
Thanks,
cj
|||You could use temp tables in the stored procedure. For example:
CREATE PROCEDURE MyProc
AS
CREATE TABLE #t(x INT PRIMARY KEY)
INSERT INTO #t VALUES (2)
SELECT * FROM #t
GO
However, in that case make sure to use the text-based query designer (with 2 panes) and keep in mind that automatically generating a schema (getting the list of fields) fails on SPs with temp tables. This automatic method is invoked when you switch from Data view to Layout view.
Instead, before going to Layout, get the schema manually by clicking on the Refresh Fields button which will manually refresh the query.
The automatic method gets a schema quickly when available without any necessary user interaction. (Behind the scenes it is running the query with SET FMTONLY ON). The manual method gets the schema by running the query. It takes longer and will prompt the user for query parameter values if required. The former works for most queries with the exceptions of temp table use or some dynamic SQL. The latter always works, but has performance drawbacks for some queries.
-- Robert
2012年2月9日星期四
basic RS questions
those things I can't find out:
1. What means "Export" to "HTML with Office web components"? It looks just
like the orginal report viewer to me, ie confusing as the first export format.
2. Is it possible to re-sort a report table on "any" report column in the
report viewer or do I have to export to excel ?
3. Where do I declare "document map pane" items ? Can't find any props.
4. Can History page be hidden in the viewer when props for this report says
it can't generate History ?
5. Is it possible to stop users (in security) to do subscriptions and if so,
will those pages/buttons dissappear in the viewer ?
/Jerome KI can help with some of this... see inline
--
Wayne Snyder MCDBA, SQL Server MVP
Mariner, Charlotte, NC
(Please respond only to the newsgroup.)
I support the Professional Association for SQL Server ( PASS) and it's
community of SQL Professionals.
"/jerome k" <jeromek@.discussions.microsoft.com> wrote in message
news:0C8E29BE-0140-4F67-AC3A-358FC894CA94@.microsoft.com...
> Hi,
> those things I can't find out:
> 1. What means "Export" to "HTML with Office web components"? It looks just
> like the orginal report viewer to me, ie confusing as the first export
> format.
This exports to a file that you can place on some other web site...
> 2. Is it possible to re-sort a report table on "any" report column in the
> report viewer or do I have to export to excel ?
If there are no groupings you can do this... Ihave some examples using SQL
2000 at www.msbicentral.com It is kind of a pain to do in SQL 2k , but SQL
2005 makes it easy. (If there are groupings you can still do it, but it
becomes more complicated.)
> 3. Where do I declare "document map pane" items ? Can't find any props.
right click on any Group, text box etc. and when the dialog box opens, go to
the navigation tab... use the document map box to enter the field info.
> 4. Can History page be hidden in the viewer when props for this report
> says
> it can't generate History ?
I Don't know..
> 5. Is it possible to stop users (in security) to do subscriptions and if
> so,
> will those pages/buttons dissappear in the viewer ?
Yes it is possible to NOT allow subscriptions, RS is role based security and
one of the privileges is whether or not a user can make subscriptions...
Simply create a new role (BrowserNoSuscriptions)... and add every permission
that a Browser role has except subscriptions and you will be good.
I do not know if the buttons disappear or not... You'll have to test it and
see.
> /Jerome K
>
Basic RS Parameter Question
Being VERY new to RS 2000 (started looking at it a week ago), I need some advice. I have a table that contains a datetime field and I have a report that is prompting for a start date and start time, along with an end date and end time (4 prompts in total). How do I combine the dates and times together to pull into the query filter? Am I even going about this the right way?
Thanks much!
If I am understanding correctly you could do something like in your filters set the
TimeValue(Fields!Example.value) = TimeValue(Parameters!Time.Value)
and you could do that for time and date if you are trying to break apart a datetime field.
Josh
|||u can add the parameters into the SQL code such as :
SELECT * FROM tbl_Name WHEREId=@.Id
The RS refer the @.Id as Parameter.
Basic Reporting Services / Analysis Services report - flattened rowset problem
I am just getting started with Reporting Services 2000 and I need some help PLEASE! My source is MSAS 2000 cube. This whole flattened rowset is confusing me. Insight will be HUGELY appreciated.
I have a MSAS hierarchy that looks like this:
WORLD
-North America
USA
Canada
Mexico
-Europe
UK
Germany
etc...
I use the following MDX to get my dataset
Select [Amount] on Columns, [World].AllMembers on ROWS From Cube
I get the following Reporting Services dataset with THREE columns:
(nothing) 5000
North America 3000
North America USA 1000
North America Canada 1000
North America Mexico 1000
Europe 2000
Europe UK 1000
Europe Germany 1000
What I want is a report that looks like this -- (Two columns)
DESIRED REPORT
Location Amount
+ North America 3000
+ Europe 2000
World 5000
When the user Clicks the + icon , The report should expand. Like below:
DESIRED REPORT AFTER DRILLDOWN
Location Amount
USA 1000
Canada 1000
Mexico 1000
+ North America 3000
+ Europe 2000
World 5000
This seems like it should be the most basic report possible for a cube with a hierarchy. However, it seems that no matter what I try, I get variations of the following:
Three columns:
Continent Country Amount
+ blank here!
+ North America (nothing!!!)
+ Europe (nothing!!!)
When a + icon is clicked I get (still no AMOUNTS!!!):
Continent Country Amount
+ blank here!
- North America (nothing!!!)
+USA (nothing!!!)
+Canada (nothing!!!)
+Mexico (nothing!!!)
+ Europe (nothing!!!)
and another clicks on USA for example yields:
Continent Country Amount
+ blank here!
- North America (nothing!!!)
-USA (nothing!!!)
1000
+Canada (nothing!!!)
+Mexico (nothing!!!)
+ Europe (nothing!!!)
The desired report is a simple report. It seems like a good candidate for a wizard. However, using the wizard, I get results such as the one above. The example above uses a wizard stepped format with subtotals and drilldown enabled.
Moving away from the wizard... If I build the report without the wizard some report rows have no titles and/or no amounts and/or amounts are repeated multiple times down the rows. The only thing I can think of is that I need to IIF statements in every row to hide these rows which seems inefficient. I think I must be doing something wrong.
Do I need to change my MDX in some way to eliminate rows with Blanks in the Continent and Country columns? Or is there something simple I can do in the report definition to make it behave differentlty?
Can someone get me started please?
This MSDN paper discusses how to work with flattened rowsets in Reporting Services, and includes some sample drilldown reports that should point you in the right direction. Basically, you can set filtering in your groups to select the right rows for a given group, or have the MDX query only return data from the lowest level:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql2k/html/olapasandrs.asp?frame=true
>>
Integrating Analysis Services with Reporting Services
Sean Boon
Microsoft Corporation
June 2004
Applies to:
Microsoft SQL Server 2000
Summary: Create a compelling solution for your customer that defines and manages great-looking Analysis Services reports, and quickly answers analytical questions to improve traditional reporting scenarios. (33 printed pages)
...
Building "Drill-Down" Reports against OLAP Data
Up until this point, all of the data contained within the example reports has belonged to only one level from each dimension. For example, if you ask the question, "What are unit sales by promotion media type?" even though the user might be given the option to select any available time period, the resulting dataset will only contain data from a single level of each dimension. The included level of the time dimension might change each time the report is executed, but for each report execution only one level of the time dimension will be referenced. What happens when you need to add interactivity to the report by allowing the users to "drill-down" on members in the table?
...
>>
|||I am having the same problem. When I run my MDX query in designer I do not get the "All" member for any of my dimensions. Displaying that member is a requirement for all of my reports.
I did review the above mentioned white paper as well as download the sample reports, however none of those reports uses the "ALL" member.
Any suggections?
Here is my simple code:
Thanks in advance !!
SELECT { [Measures].[Responses], [Measures].[Responders], [Measures].[Trans Amount] } ON COLUMNS,
{ { { [Providers].Members} * { [Product].Members } * { [Channel].Members } } }
Dimension Properties Member_Unique_Name ON ROWS
FROM [Programmatic_Balance_Build]
The problem with returning an "All" member in a flattened rowset is discussed elsewhere in the above paper:
>>
Another behavior of the flattening algorithm is that the "[(ALL)]" level is not included in the dataset. This has a couple of implications. The first is that if you want to include data from the "All" member of a dimension, you'll need to create a calculated member to represent this member. This can be accomplished in a couple of different ways. The first method would be to create a calculated member on the Measures dimension and for the definition of the calculated member refer to the current member's name or unique name. There are several examples of this method represented in later sections of this whitepaper.
Note The "All" level of a dimension is not included in the field set that is returned to Reporting Services.
The second implication of the "All" level not being represented in the dataset is that calculated members, usually defined without a parent member, will need to change so that they do have a parent member. This only applies in cases where the calculated member does not belong to the Measures dimension. In many cases, when calculated members are defined on a non-Measures dimension, the parent member property is left blank. This can be changed in the calculated member dialog box as shown below
>>
|||Thank you Deepak -
This whitepaper opened up a lot of concepts for RS and AS. It was just what I needed. Thank you for pointing me in this direction.
I still don't like some of the integration issues between RS and AS . But I now understand the behaviors and work with them. And most importantly, still deliver the reports.
Basic Reporting Services / Analysis Server report - flattened rowset problem
help PLEASE! My source is MSAS 2000 cube. This whole flattened rowset
is confusing me. Insight will be HUGELY appreciated.
I have a MSAS hierarchy that looks like this:
WORLD
-North America
--USA
--Canada
--Mexico
-Europe
--UK
--Germany
--etc...
I use the following MDX to get my dataset
Select [Amount] on Columns, [World].AllMembers on ROWS From Cube
I get the following Reporting Services dataset with THREE columns:
(nothing) 5000
North America 3000
North America USA 1000
North America Canada 1000
North America Mexico 1000
Europe 2000
Europe UK 1000
Europe Germany 1000
What I want is a report that looks like this -- (Two columns)
DESIRED REPORT
Location Amount
+ North America 3000
+ Europe 2000
World 5000
When the user Clicks the + icon , The report should expand. Like
below:
DESIRED REPORT AFTER DRILLDOWN
Location Amount
USA 1000
Canada 1000
Mexico 1000
+ North America 3000
+ Europe 2000
World 5000
This seems like it should be the most basic report possible for a cube
with a hierarchy. However, it seems that no matter what I try, I get
variations of the following:
Three columns:
Continent Country Amount
+ blank here!
+ North America (nothing!!!)
+ Europe (nothing!!!)
When a + icon is clicked I get (still no AMOUNTS!!!):
Continent Country Amount
+ blank here!
- North America (nothing!!!)
+USA (nothing!!!)
+Canada (nothing!!!)
+Mexico (nothing!!!)
+ Europe (nothing!!!)
and another clicks on USA for example yields:
Continent Country Amount
+ blank here!
- North America (nothing!!!)
-USA (nothing!!!)
1000
+Canada (nothing!!!)
+Mexico (nothing!!!)
+ Europe (nothing!!!)
The desired report is a simple report. It seems like a good candidate
for a wizard. However, using the wizard, I get results such as the one
above. The example above uses a wizard stepped format with subtotals
and drilldown enabled.
Moving away from the wizard... If I build the report without the wizard
some report rows have no titles and/or no amounts and/or amounts are
repeated multiple times down the rows. The only thing I can think of
is that I need to IIF statements in every row to hide these rows which
seems inefficient. I think I must be doing something wrong.
Do I need to change my MDX in some way to eliminate rows with Blanks in
the Continent and Country columns? Or is there something simple I can
do in the report definition to make it behave differentlty?
Can someone get me started please?Joel,
The reason you're getting the blank row is because of the 'total' rows
in your dataset (ie North America <blank> 3000). The alternative would
be to remove this total row (via modifying your MDX) and letting the
report total for the continent by doing a SUM on the Amount col.
Check the visibility property of the Amount textbox to make sure it is
toggled by the [+] Continent textbox.
Also, to hide duplicates, there is a property on a Textbox which will
hide repeated values.
Hopefully that will get you started.
Andy Potter|||Thank you for your response -
For your first suggestion, do you mean to create a row in the report
with formula USA+Canada+Mexica and a second row with formula
UK+Germany? This isn't really my hierarchy, in reality, the dimension
has 7 levels and hundreds of thousands of members so manual totals are
not an option.
Or do you mean to suppress the rows with a blank via my MDX? If so,
any ideas on how to formulate this?
I tried the toggle for the amount text box and it has no effect. the
Hide Repeated on the Amount text box has no effect either. I tried
hiding repeats for amount conditioned on Continent and Country.|||Thank you for your response -
For your first suggestion, do you mean to create a row in the report
with formula USA+Canada+Mexica and a second row with formula
UK+Germany? This isn't really my hierarchy, in reality, the dimension
has 7 levels and hundreds of thousands of members so manual totals are
not an option.
Or do you mean to suppress the rows with a blank via my MDX? If so,
any ideas on how to formulate this?
I tried the toggle for the amount text box and it has no effect. the
Hide Repeated on the Amount text box has no effect either. I tried
hiding repeats for amount conditioned on Continent and Country.|||Thank you for your response -
For your first suggestion, do you mean to create a row in the report
with formula USA+Canada+Mexica and a second row with formula
UK+Germany? This isn't really my hierarchy, in reality, the dimension
has 7 levels and hundreds of thousands of members so manual totals are
not an option.
Or do you mean to suppress the rows with a blank via my MDX? If so,
any ideas on how to formulate this?
I tried the toggle for the amount text box and it has no effect. the
Hide Repeated on the Amount text box has no effect either. I tried
hiding repeats for amount conditioned on Continent and Country.
Basic Report & Report is being generated
I'm able to execute the command under the data tab with no problems. I'm able to view built in reports for SQL Server 2005. I've tried restarting Visual Studio and the entire PC but the report will still no generate.
Thoughts or ideas about what my problem is?
SQL Server 2005 SP1
Thanks,
MikeTurns out if I move the solution to a location on my local machine as opposed to a UNC, the report generated just fine. I'm pretty sure it would eventually generate on the UNC it would just take forever!
Mike|||I have this same issue and I'm not writing to a UNC path, could there be any other reasons?