Click here to Skip to main content
15,887,341 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to render a report as PDF in window service.While calling is correct of function getReportFrmServer

My code is

C#
 DailyReportFile = getReportFrmServer(reportName, param);
public byte[] getReportFrmServer(string report, string[] param)
        {
  if (report == "DailyAttendanceReport")
                {
                    
                  
                    List<ReportParameter> myParams = new List<ReportParameter>();
                    myParams.Add(new ReportParameter("dailyDate", param[0]));
                    ReportParameter p = new ReportParameter("contractorname");
                    if (param[1] == "")
                    {
                        p.Values.Add(null);
                        myParams.Add(p);
                    }
                    else
                    {
                        p.Values.Add(param[1]);
                        myParams.Add(p);
                    }
                    ReportParameter q = new ReportParameter("sitename");
                    if (param[2] == "")
                    {
                        q.Values.Add(null);
                        myParams.Add(q);
                    }
                    else
                    {
                        q.Values.Add(param[2]);
                        myParams.Add(q);
                    }
                    this.reportViewer1.ProcessingMode = ProcessingMode.Local;

                    this.reportViewer1.LocalReport.DataSources.Clear();
                    ReportDataSource DS = new ReportDataSource("DailyAttendanceReport", fillrel(param[0], param[1], param[2]));
                    reportViewer1.LocalReport.DataSources.Add(DS);
                    this.reportViewer1.LocalReport.ReportPath = @"c:\ReportSource\DailyAttendanceReport.rdl";
  this.reportViewer1.LocalReport.SetParameters(myParams);
    byte[] returnValue = null;
            string format = "PDF";
            string deviceinfo = "";
            string mimeType = "";
            string encoding = "";
            string extension = "pdf";
            string[] streams = null;
            Warning[] warnings = null;
  returnValue = reportViewer1.LocalReport.Render(format, deviceinfo, out mimeType, out encoding, out extension, out streams, out warnings);// Exception is here
                reportViewer1.LocalReport.Refresh();  
}
 public DataTable fillrel(string date,string name,string site)
        {
            string query = "select * from IA3000SDB.dbo.Util(@dailyDate,@contractorname,@sitename)";
            DataSet dataset = new DataSet();
            try
            {
                con.Open();
                cmd = new SqlCommand(query, con);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.AddWithValue("@dailyDate", date);
                cmd.Parameters.AddWithValue("@contractorname", name);
                cmd.Parameters.AddWithValue("@sitename", site);
                ad = new SqlDataAdapter(cmd);
                ad.Fill(dataset);
                if (dataset.Tables[0].Rows.Count > 0)
                {
                    return dataset.Tables[0];
                }
                else
                {
                    return null;
                }
            }
            catch (Exception ex)
            {
                return null;
            } 
        }



InnerException is {"An error occurred during local report processing."}
Exception is {"An error occurred during local report processing."}
Posted
Updated 19-Jul-13 22:05pm
v2

1 solution

CSS
An error occurred during local report processing.
The definition of the report 'Main Report' is invalid.
The report definition is not valid. Details: The report definition has an invalid target namespace 'http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition' which cannot be upgraded.
 
Share this answer
 
Comments
Deepu S Nair 15-Apr-15 6:45am    
Don't post your question as solution.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900