Friday, March 9, 2012

How to set Parameters with ExecutionService?

Hello, I havent been able to set parameters with the reportexecutionservice.

I also need to send a multivalue parameter, any ideas?

ExecutionInfo execInfo;

execInfo = rs.LoadReport(path, null);

ReportParameter pEmpresa = new ReportParameter()

pEmpresa = (ReportParameter)DropDownList1.SelectedValue;

execInfo.Parameters[0] = pEmpresa;

execInfo.Parameters[1] = DropDownList2.SelectedValue;

//rs.SetExecutionParameters();

StringBuilder selectected = new StringBuilder();

for (int i = 0; i < CheckBoxList1.Items.Count; i++)

{

if (CheckBoxList1.ItemsIdea.Selected)

{

selectected.Append(CheckBoxList1.SelectedValue);

selectected.Append(",");

}

}

execInfo.Parameters[2] = selectected;

But I have the following errors

Error 13 Cannot convert type 'string' to 'RSExecution.ReportParameter' C:\Inetpub\wwwroot\GescomDllo\Protected\01_Administradores\rpt_clasificacioncompetencias.aspx.cs 550 20 http://localhost/GescomDllo/

Error 14 Cannot implicitly convert type 'string' to 'RSExecution.ReportParameter' C:\Inetpub\wwwroot\GescomDllo\Protected\01_Administradores\rpt_clasificacioncompetencias.aspx.cs 553 34 http://localhost/GescomDllo/

Error 15 Cannot implicitly convert type 'System.Text.StringBuilder' to 'RSExecution.ReportParameter' C:\Inetpub\wwwroot\GescomDllo\Protected\01_Administradores\rpt_clasificacioncompetencias.aspx.cs 568 34 http://localhost/GescomDllo/

I solved it a little , but I am still having problems with multivalue parameters

ExecutionInfo execInfo;

execInfo = rs.LoadReport(path, null);

ParameterValue pNmEmpresa= new ParameterValue();

pNmEmpresa.Name = "NmEmpresa";

pNmEmpresa.Value = DropDownList1.SelectedValue;

ParameterValue pNmCiclo = new ParameterValue();

pNmCiclo.Name = "NmCiclo";

pNmCiclo.Value = DropDownList2.SelectedValue;

////rs.SetExecutionParameters();

StringBuilder selectected = new StringBuilder();

for (int i = 0; i < CheckBoxList1.Items.Count; i++)

{

if (CheckBoxList1.ItemsIdea.Selected)

{

selectected.Append(CheckBoxList1.SelectedValue);

selectected.Append(",");

}

}

ParameterValue pNmTiposCompetencia = new ParameterValue();

//pNmTiposCompetencia.Name = "NmTipoCompetencia";

//pNmTiposCompetencia.Value = "12";

string[] nmtiposcompetencia = selectected.ToString().Split(new char[] { ',' });

for (int i=0; i <= nmtiposcompetencia.Length ; i++)

{

pNmTiposCompetenciaIdea.Name = "NmTipoCompetencia";

pNmTiposCompetenciaIdea.Value = nmtiposcompetenciaIdea;

//pNmTiposCompetencia.ValueIdea = "12";

}

ParameterValue[] parametros = new ParameterValue[3]{pNmEmpresa,pNmCiclo,pNmTiposCompetencia};

rs.SetExecutionParameters(parametros, null);

|||

Almost done, I hardcoded the parameters and I saw that each value selected in the checkboxlist is a parameter, so thats a problem because I cant know the number of parameters

I am trying something like this with no luck yet,

I hope somebody to give me a hand.

The 2 constant is because I already know to parameters that come from two different dropdownlist.

StringBuilder selectected = new StringBuilder();

int TiposCompetenciasSeleccionadas = 0;

ArrayList al = new ArrayList();

for (int i = 0; i < CheckBoxList1.Items.Count; i++)

{

if (CheckBoxList1.ItemsIdea.Selected)

{

selectected.Append(CheckBoxList1.SelectedValue);

selectected.Append(",");

al.Add(CheckBoxList1.SelectedValue);

TiposCompetenciasSeleccionadas++;

}

}

ParameterValue[] parametros = new ParameterValue[2 + TiposCompetenciasSeleccionadas] { pNmEmpresa, pNmCiclo };

for (int i = 0; i < parametros.Length; i++)

{

parametros[i+2].Name ="NmTipoCompetencia";

parametros[i+2].Value = alIdea;

}

string[] nmtiposcompetencia = selectected.ToString().Split(new char[] { ',' });

rs.SetExecutionParameters(parametros, null);

No comments:

Post a Comment