Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 以编程方式控制SQL Server Reporting Services报表查看器_C#_Asp.net_Reporting Services - Fatal编程技术网

C# 以编程方式控制SQL Server Reporting Services报表查看器

C# 以编程方式控制SQL Server Reporting Services报表查看器,c#,asp.net,reporting-services,C#,Asp.net,Reporting Services,我对SSRS的ReportViewer控件的ASP.NET版本有问题 在我的ASP.NET web表单文件中,我有: <rsweb:ReportViewer ID="webViewer" runat="server" Width="100%" Height="100%" ProcessingMode="Remote"> <ServerReport ReportPath="/AnalyticReports/SiteOverview"

我对SSRS的ReportViewer控件的ASP.NET版本有问题

在我的ASP.NET web表单文件中,我有:

    <rsweb:ReportViewer ID="webViewer" runat="server" Width="100%" Height="100%" 
        ProcessingMode="Remote">
        <ServerReport ReportPath="/AnalyticReports/SiteOverview" 
            ReportServerUrl="http://someserver/ssrs" />
    </rsweb:ReportViewer>
然而,这似乎没有任何作用。我甚至尝试添加webViewer.Reset(),但没有效果


有人给我指出正确的方向吗?

劳埃德,你试过这个吗

webViewer.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Remote;

我使用LocalReport,它似乎工作得更好:

var reportDataSource = new ReportDataSource("DataSet1", resultSet);

ReportViewer1.LocalReport.ReportPath = Server.MapPath("/Reports/" + reportName + ".rdl");
ReportViewer1.LocalReport.DataSources.Clear();
ReportViewer1.LocalReport.DataSources.Add(reportDataSource);

ReportViewer1.LocalReport.Refresh();

实际上,问题似乎在于
Page\u Load
事件。遇到问题后,我尝试了
Page\u Init
,事情似乎按预期进行。

我使用了一个属性来获取和设置值

public string ReportPathString 
{ get { return ReportViewer1.ServerReport.ReportPath; } 
  set { ReportViewer1.ServerReport.ReportPath = value; } 
}

public string ReportServerUrlString 
{ get { return ReportViewer1.ServerReport.ReportServerUrl.ToString(); } 
  set { ReportViewer1.ServerReport.ReportServerUrl = new Uri(value); } 
}
另外,在页面加载时,我使用以下代码设置凭据

IReportServerCredentials irsc = new ReportServerCredentials("Username", "Password", "Domain");
使用的类如下所示

public class ReportServerCredentials : IReportServerCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;

public ReportServerCredentials(string UserName, string PassWord, string DomainName)
{
    _UserName = UserName;
    _PassWord = PassWord;
    _DomainName = DomainName;
}

public System.Security.Principal.WindowsIdentity ImpersonationUser
{
    // use default identity
    get { return null; }
}

public ICredentials NetworkCredentials
{
    // use default identity
    get { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
}

public bool GetFormsCredentials(out Cookie authCookie, out string user,
 out string password, out string authority)
{
    authCookie = null;
    user = password = authority = null;
    return false;
}


}

编辑:刚刚看到的主题是一年前的…

是的,我试过了。当前它在控件标记中,但我也尝试显式设置它。您是否验证了远程服务器上的连接字符串和权限是否都正常?报表查看器是否立即返回空白或超时?是。就像我说的,它与标记中硬编码的设置一起工作,报告运行良好,返回等等。愚蠢的问题——但是您确定为ReportServer设置值的语句已经设置好了吗?这些语句在哪里?在aspx页面的Page_Load事件中。我很确定他们已经准备好了。让我们看看剩下的代码;也许问题在于,在这种情况下,本地报告对我们来说是不可能的:(在我的情况下,它们对服务器来说是“本地的”。我们仍然使用web viewer,用户看不到任何区别。
public class ReportServerCredentials : IReportServerCredentials
{
private string _UserName;
private string _PassWord;
private string _DomainName;

public ReportServerCredentials(string UserName, string PassWord, string DomainName)
{
    _UserName = UserName;
    _PassWord = PassWord;
    _DomainName = DomainName;
}

public System.Security.Principal.WindowsIdentity ImpersonationUser
{
    // use default identity
    get { return null; }
}

public ICredentials NetworkCredentials
{
    // use default identity
    get { return new NetworkCredential(_UserName, _PassWord, _DomainName); }
}

public bool GetFormsCredentials(out Cookie authCookie, out string user,
 out string password, out string authority)
{
    authCookie = null;
    user = password = authority = null;
    return false;
}


}