代码之家  ›  专栏  ›  技术社区  ›  Chris Conway

SQL Reporting Services数据连接更新

  •  2
  • Chris Conway  · 技术社区  · 16 年前

    是否可以更改已发布的SQL Reporting Services报表的连接字符串?我可以在ReportServer数据库中看到名为datasource的二进制字段,但由于它存储为二进制,我认为它不容易更新。

    是否需要使用正确的数据源重新发布报表?我不希望,因为我不想安装VS2003。

    编辑:客户端正在运行安装了所有服务包的SQL Server 2000 Reporting Services。

    1 回复  |  直到 16 年前
        1
  •  1
  •   Scott Saad    16 年前

    SQL Reporting Services 2000具有[Web服务]。( http://msdn.microsoft.com/en-us/library/aa274396(SQL.80).aspx) 可用于更改数据源的。鉴于此,下面允许将数据源更改为共享数据源。这是[改编自msdn]。( http://msdn.microsoft.com/en-us/library/aa225896(SQL.80).aspx) .

    // Create our reporting services class
    ReportingService theRS = new ReportingService();
    theRS.Credentials = System.Net.CredentialCache.DefaultCredentials;
    
    // We need to setup a data source reference to an existing shared data source
    DataSourceReference theDSRef = new DataSourceReference();
    theDSRef.Reference = "/Path/To/ExistingSharedDataSource";
    DataSource[] theDSArray = new DataSource[1];
    DataSource theDS = new DataSource();
    theDS.Item = (DataSourceReference)theDSRef;
    theDS.Name = "NameOfSharedDataSource";
    theDSArray[0] = theDS;
    
    try
    {
        // Attempt to change the data source of the report
        theRS.SetReportDataSources("/Path/To/ReportName", theDSArray);
        Console.Out.WriteLine("We have changed the data source");
    }
    catch (System.Web.Services.Protocols.SoapException e)
    {
        Console.Out.WriteLine(e.Message);
        Console.Out.WriteLine(e.Detail.InnerXml.ToString());
    }
    

    在这个例子中, 报告服务 类是从我生成用于与Web服务对话的代理类中获取的,如[此处]所述。( http://msdn.microsoft.com/en-us/library/aa256607(SQL.80).aspx) .

    我希望这对一些人有帮助。如果你在找不同的东西,请告诉我。