設定Reporting Services角色認證

設定Reporting Services角色認證

Reporting Services角色認證,另一種更簡單的方式

 

 

 static public void SetRsCredentials(ReportViewer reportViewer1)
    {
        System.Net.ICredentials credentials = new System.Net.NetworkCredential(cConn.gsRS_User, cConn.gsRS_PWD, cConn.gsRS_Domain);
        ReportServerCredentials rsCredentials = reportViewer1.ServerReport.ReportServerCredentials;
        rsCredentials.NetworkCredentials = credentials;
    }
            //設定角色認證
            SetRsCredentials(reportViewer1);
            //設定報表伺服器路徑
            reportViewer1.ServerReport.ReportServerUrl = new Uri("http://RSServerName/ReportServer");
            reportViewer1.ServerReport.ReportPath = @"/COS/RPT_TurnPaymentStat";
            //設定報表參數
            List ParamList = new List ();
            ParamList.Add(new ReportParameter("TURN_PCAY_Y", mskPcayDate.Text));
            ParamList.Add(new ReportParameter("DATA_YM_S", mskTurnDateS.Text));
            ParamList.Add(new ReportParameter("DATA_YM_E", mskTurnDateE.Text));
            this.reportViewer1.ServerReport.SetParameters(ParamList);
            this.reportViewer1.RefreshReport();