Para invocar un reporte que se encuentre dentro del servidor de reporte solo debemos especificar los datos dentro de nuestro ReportViewer de la siguiente manera:
ReportViewer1.ProcessingMode = ProcessingMode.Remote;
ReportViewer1.ServerReport.ReportServerUrl = new Uri("http://Servidor//");
ReportViewer1.ServerReport.ReportPath = "Reportes" + "/" + "Reporte.rdl";
//de esta manera podemos obtener los parámetros que va recibir el reporte y pasárselos:
List param = new List();
var listPara = ReportViewer1.ServerReport.GetParameters();
for (int i = 0; i < listPara.Count; i++)
{
param.Add(new ReportParameter(listPara[i].Name, "Valor Prametro",false));
}
ReportViewer1.ServerReport.SetParameters(param);
ReportViewer1.ServerReport.Refresh();
Si el reporte necesita credenciales para conectarse se debe usar de la siguiente manera:
ReportViewer1.ServerReport.ReportServerCredentials = new CustomReportCredentials("User", "Password", "Dom");
y para usar la clase de CustomReportCredentials debemos crearla dentro de la pagina donde este llamando el reporte de la siguiente manera:
public class CustomReportCredentials : Microsoft.Reporting.WebForms.IReportServerCredentials
{
// local variable for network credential.
private string _UserName;
private string _PassWord;
private string _DomainName;
private WindowsIdentity _ImpersonationUser;
public CustomReportCredentials(string UserName, string PassWord, string DomainName)
{
_UserName = UserName;
_PassWord = PassWord;
_DomainName = DomainName;
// _ImpersonationUser = ImpersonationUser;
}
public WindowsIdentity ImpersonationUser
{
get
{
return null; // not use ImpersonationUser
}
}
public ICredentials NetworkCredentials
{
get
{
// use NetworkCredentials
return new NetworkCredential(_UserName, _PassWord, _DomainName);
}
}
public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
// not use FormsCredentials unless you have implements a custom autentication.
authCookie = null;
user = password = authority = null;
return false;
}
}