Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SSRS PDF
I am getting the error "the source of report definition has not been specified",kindly help me this is my code
 
ReportViewer ReportViewer1 =null;
        try
        {
            rptData = new DataSet();
            objReportHelper = new ReportHelper();
 
            ReportViewer1 = new ReportViewer();
            ReportViewer1.Reset();
            if (Session["ReporttHelperObject"] != null)
            {
                objReportHelper = (ReportHelper)Session["ReporttHelperObject"];
 
                this.Title = objReportHelper.ReportMode.ToString().Replace("_", " ");
 
                rptData.ReadXmlSchema(Server.MapPath("Reports/DataSets/spReport_LoanSummaryBatchOther.xsd"));
 
                for (int i = 0; i < 5; i++)
                {
                    rptData.Tables[0].Rows.Add();
                    foreach (DataColumn dCol in rptData.Tables[0].Columns)
                    {
                        rptData.Tables[0].Rows[i][dCol.ColumnName] = dCol.DefaultValue;
                    }
                }
                //-------------------------------------------------------------
 
                ReportViewer1.ProcessingMode = ProcessingMode.Local;
                LocalReport rep = ReportViewer1.LocalReport;
                rep.Refresh();
                rep.ReportPath = "Reports/BatchOtherComments.rdlc";
 
                rptData.DataSetName = "spReport_LoanSummaryBatchOther";
                objReportDataSource = new ReportDataSource("spReport_LoanSummaryBatchOther", rptData.Tables[0]);
                //ReportViewer1.LocalReport.ReportPath = "Reports/BatchOtherComments.rdlc";
                rep.DataSources.Add(objReportDataSource);
             //   ReportViewer1.LocalReport.ReportEmbeddedResource = "Reports/BatchOtherComments.rdlc";
                //        byte[] rdlbytes = System.Text.Encoding.UTF8.GetBytes("Reports/rptDeniedLoansDetails.rdlc");
                //MemoryStream stream = new MemoryStream(rdlbytes);
                //ReportViewer1.LocalReport.LoadReportDefinition(stream);
 
 
                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();
        }
 
Posted 17-Oct-12 3:45am
Ali_1001.3K

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 515
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 155
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web01 | 2.8.1411028.1 | Last Updated 17 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100