尚未指定报告定义的来源

时间:2012-10-18 12:06:36

标签: reporting-services

我收到以下错误

the source of report definition has not been specified

以下是我正在使用的代码

ReportViewer ReportViewer1 =null;

ReportPath = "Reports/BatchOtherComments.rdlc";
...
        rptData.DataSetName = "spReport_LoanSummaryBatchOther";
        objReportDataSource = new ReportDataSource("spReport_LoanSummaryBatchOther", rptData.Tables[0]);
        rep.DataSources.Add(objReportDataSource);

        Warning[] warnings;
        string mimeType;
        string encoding;
        string extension;
        string deviceInfo;
        string[] streamids;
        deviceInfo =
          "<DeviceInfo>" +
          "  <OutputFormat>PDF</OutputFormat>" +
          "  <PageSize>A4</PageSize>" +
          "  <PageWidth>8.5in</PageWidth>" +
          "  <PageHeight>11in</PageHeight>" +
          "  <MarginTop>0.25in</MarginTop>" +
          "  <MarginLeft>0.25in</MarginLeft>" +
          "  <MarginRight>0.25in</MarginRight>" +
          "  <MarginBottom>0.25in</MarginBottom>" +
          "</DeviceInfo>";
        byte[] bytes = ReportViewer1.ServerReport.Render("PDF", null, out mimeType, out encoding, out extension, out streamids, out warnings);
        FileStream fs = new FileStream(@"C:/Users/wnaeem/Sample.PDF", FileMode.Create);
        fs.Write(bytes, 0, bytes.Length);
        fs.Close();
    }
}
catch (Exception ex)
{
    throw ;
}
finally
{
    ReportViewer1.Dispose();
}

0 个答案:

没有答案