|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:07 PM
Points: 9,
Visits: 56
|
|
Gettings Everyone !!  I'm new to SSRS and really need some help from you experts in this Forum -- I created a SSIS package and in a "Script Task" (using C# as language) I've established connection using web service to 'talk' to a report -- code below: public void Main() { ReportingService2010 rs = new ReportingService2010(); rs.Credentials = System.Net.CredentialCache.DefaultCredentials; rs.Url = http://somesever:8080/ReportServer_SQL01/reportservice2010.asmx?wsdl; string report = "/ABM/ABM_REPORTS/Master/SSIS Linked Monthly Report"; bool forRendering = false; string historyID = null; ParameterValue[] values = null; DataSourceCredentials[] credentials = null; ItemParameter[] parameters = null; int counter = 0; try { parameters = rs.GetItemParameters(report, historyID, forRendering, values, credentials); if (parameters != null) { foreach (var rp in parameters) { counter++; Console.WriteLine(counter.ToString()); Console.WriteLine("Name: {0}", rp.Name); Console.WriteLine("Prompt: ", rp.Prompt); if (rp.PromptUser == true) Console.WriteLine("PromptUser is true"); } } } catch (SoapException e) { Console.WriteLine(e.Detail.InnerXml.ToString()); } Dts.TaskResult = (int)ScriptResults.Success; } Output: 1 Name: databaseName Prompt: PromptUser is true 2 Name: centre Prompt: PromptUser is true 3 Name: processDate Prompt: PromptUser is true Microsoft (R) SQL Server Execute Package Utility Version 10.50.1600.1 for 32-bit Copyright (C) Microsoft Corporation 2010. All rights reserved. I was able to print out everything retrived from the GetItemParameters Method HOWEVER I don't know how to SET (assign a defauilt value to the first parameter and then Hide it so when user access thereport they'll be promoted form 2nd parameter onward) the first parameter "databaseName" -- what I want to Achieve is assign the database name to a spesific one and hide it from user , so user only need to enter 'centre' and 'process date' when they try to run this report. HELP!! HELP!! Greatly Appreciated!!!!!! Tags:
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:07 PM
Points: 9,
Visits: 56
|
|
I'm going to reply to myself 
I got this far -- but the last piece having problems:
Code:
parameters = rs.GetItemParameters(report, historyID, forRendering, values, credentials);
Console.WriteLine("parameters[0].Name = " + parameters[0].Name);
Console.WriteLine("parameters[0].DefaultValues = " + parameters[0].DefaultValues);
The above 3 lines of code worked and I got the output:
parameters[0].Name = databaseName parameters[0].DefaultValues =
Now All I want to do is to assign a Default Falue for this first parameter (parameters[0], databaseName) so I go:
rs.SetItemParameters(report, parameters[0].DefaultValues.SetValue("My_DB_Name", ???));
For the '???' part no matter what I put (tried '2', 'parameters[0]' ) it wouldn't satisfy the complier -- keeps compalining "The best overloaded method match for 'System.Array.SetValue(object, params long[])' has some invalid arguments" ...
Can someone give me some tips on WHAT should be inside the ( ) for SetValue ??? THAHK YOU SO MUCH!!!
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:07 PM
Points: 9,
Visits: 56
|
|
Further -- when I I put in code:
rs.SetItemParameters(report, parameters[0].DefaultValues.SetValue("My_DB_Name", 0));The compiler compalins: Argument '2': cannot convert from 'void' to 'ST_a6ff246c0xxxc.csproj.ReportService2010.ItemParameter[]' The long sting is the namespace Any iders/hints/tips anything will be greatly appreciated !!!
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, April 04, 2013 4:58 AM
Points: 52,
Visits: 163
|
|
You need to create an array of ItemParameter and pass it to the function. Below is the sample code:
ItemParameter[] param = new ItemParameter[1]; param[0] = new ItemParameter(); param[0].Name = "parameter1"; //Give parameter name here param[0].DefaultValues = new string[] {"0"}; //Give parameter value here rService.SetItemParameters("ReportPath/ReportName", param);
Hope this helps..!!!
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, April 04, 2013 4:58 AM
Points: 52,
Visits: 163
|
|
Your code should be like below:
parameters[0].DefaultValues = new string[] {"My_DB_Name"}; rs.SetItemParameters(report, parameters);
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, May 10, 2013 2:07 PM
Points: 9,
Visits: 56
|
|
THANK YOU SO Much Ravi -- it totally worked! I was able to assign value to the first parameter of a (freshly created) Linked Report and then 'hide' this parameter so that when user pull this report they can only select form 2nd parameter onward --
...... parameters[0].DefaultValue[0] = "My_dbName_1"; parameters[0].PromptUser = false;
rs.SetItemParameters(report, parameters);
This is a critical step for our solution since we have over 20 different SSRS reports and against 10 clients -- each client is a database on the same SQL Server engine (My_dbName_1, My_dbName_2 ....with Identical Schema) so we've created the 20 reports in a generic way by having DB Name as very first parameter and deploy to a "Master" location on report server, and then, using the "Script Task" in a SSIS package via Web Service we create a report folder for each client and then generate 20 "Linked Reports" for each DB from 'master" to that folder -- the last step would be assign the dbName as default value for all reports for each client/database so that user can't see other client's data (security controlled by URL permission) ..... Now with your help our solution is completely automated Thanks again!
This pretty heavy stuff for a Sybase/SQL Server DBA But I'm glad it worked !!
|
|
|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Thursday, April 04, 2013 4:58 AM
Points: 52,
Visits: 163
|
|
Good to know it helped and you have something automated
|
|
|
|