2011-02-18 17 views
0

我有一個帶有子報表的reportviewer報表。當我部署到另一臺服務器時,在本地運行報告工作正常,爲遠程計算機上的本地用戶獲取SQL訪問拒絕錯誤。例如ReportViewer - 子報表處理模擬上下文

訪問被拒絕服務器名\服務器$

我有一種感覺,這是因爲我燒一個SQL命令來獲取所需的子報告中的數據,並在服務器上部署時,報表查看器在觸發此命令並且因爲我的所有連接字符串都使用集成安全性(出於安全原因),因此它沒有得到正確的模擬上下文。

我的數據庫訪問類是在不同的裝配比報表組件,這兩個組件都是從Web應用程序中引用

看來報表查看器在調用子報表處理事件時,它需要得到數據爲子報告。 Web應用程序在運行時模擬用戶,但子報表處理事件不使用此指定用戶。相反,也許是本地系統帳戶,而且連接字符串正在使用集成安全性,本地系統帳戶無法訪問另一臺服務器上的數據庫。

其他人有這個問題嗎?

這裏就是我想我已經得到了這條底線爲我的報告頁面

/// <summary> 
     /// Page Load 
     /// </summary> 
     /// <param name="sender"></param> 
     /// <param name="e"></param> 
     protected void Page_Load(object sender, EventArgs e) 
     { 
      try 
      { 
       if (!Page.IsPostBack) 
       { 
        Reporting.Common.SetReportEmbeddedResource(this.ReportViewer1, "xxx.Web.WAP.Reporting.Reports.ApprovalRouteHeader.rdlc"); 

        this.ReportViewer1.LocalReport.DataSources.Add(
         new Microsoft.Reporting.WebForms.ReportDataSource(
          "CostDept", 
          Reporting.Repositories.ApprovalRoute.GetHeaderApprovalRouteList())); 

        this.ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local; 
        this.ReportViewer1.LocalReport.SubreportProcessing += new Microsoft.Reporting.WebForms.SubreportProcessingEventHandler(LocalReport_SubreportProcessing); 

        this.ReportViewer1.LocalReport.Refresh(); 
       } 
      } 
      catch (Exception ex) 
      { 
       ErrorLogging.LogError(ex); 
      } 
     } 

     /// <summary> 
     /// Loads the sub report 
     /// </summary> 
     /// <param name="sender">object</param> 
     /// <param name="e">args</param> 
     protected void LocalReport_SubreportProcessing(object sender, Microsoft.Reporting.WebForms.SubreportProcessingEventArgs e) 
     { 
      try 
      { 
       e.DataSources.Add(
        new Microsoft.Reporting.WebForms.ReportDataSource(
         "CostDept", 
         Reporting.Repositories.ApprovalRoute.GetDetailApprovalRouteList(
         Convert.ToInt32(e.Parameters[ "AccountNumberID" ].Values[ 0 ]), 
         Convert.ToInt32(e.Parameters[ "SageDatabaseID" ].Values[ 0 ]), 
         Convert.ToInt32(e.Parameters[ "RequestingUserID" ].Values[ 0 ]), 
         Convert.ToInt32(e.Parameters[ "ProjectID" ].Values[ 0 ]), 
          Convert.ToInt32(e.Parameters[ "ProjectItemID" ].Values[ 0 ]), 
         e.Parameters[ "DocumentType" ].Values[ 0 ].ToString()))); 
      } 
      catch (Exception ex) 
      { 
       ErrorLogging.LogError(ex); 
      } 
     } 

回答

0

的代碼。由於SQL服務器位於Web應用程序的獨立框中,因此在處理子報表時會導致「雙跳」,從而導致身份上下文丟失。

我想出了2個解決方法。

1)使用UID和PWD在SQL連接字符串,以便集成安全性不使用

2)在IIS應用程序池和匿名用戶訪問的身份更改爲具有數據庫的訪問權限相同的帳戶。然後,當處理子報告時,應用程序池的標識將有權訪問並且將正確加載。

我貼在我的博客mored詳細的解釋: WraithNath

0

我遇到了類似的情況導入圖成圖像。

我的圖表通過一個aspx頁面呈現,並具有動態參數。在本地運行時,它運行良好。部署到我們的分段盒......它打破了。與此處提到的子報告問題相同的錯誤。

我終於剛剛從圖表渲染中刪除了安全性(我們已經在所有數據庫連接中使用了UID/PWD)。

所以我認爲這個問題幾乎發生在報表控件的任何「子」任務上。無論是調用圖像,子報告還是其他任何內容。