Click here to Skip to main content
15,892,809 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

I want to generate SSRS from Codes that is .rdlc extension files Please rectify my code I used in my page.
C#
DataTable dt = new DataTable();
       dt=Tray.fillProjects();
            try
            {
                if (dt.Rows.Count > 0)
                {
                    ReportDocument rptdoc = new ReportDocument();
                    rptdoc.Load(Server.MapPath("~\\Reports\\Tremor.rdlc"));
                    rptdoc.SetDataSource(dt);
                 
                    crv.ReportSource = rptdoc;
                    crv.DataBind();

                    ExportOptions exportOpts1 = rptdoc.ExportOptions;
                    rptdoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
                    rptdoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
                    rptdoc.ExportOptions.DestinationOptions = new DiskFileDestinationOptions();
                    ((DiskFileDestinationOptions)rptdoc.ExportOptions.DestinationOptions).DiskFileName = Server.MapPath("Tremor.pdf");
                    rptdoc.Export();
                    rptdoc.Close();
                    rptdoc.Dispose();
                    Response.ClearContent();
                    Response.ClearHeaders();
                    Response.ContentType = "application/pdf";
                    Response.AppendHeader("Content-Disposition", "attachment; filename=Tremor.pdf");
                    Response.WriteFile("Tremor.pdf");
                    Response.Flush();
                    Response.Close();
                   System.IO.File.Delete(Server.MapPath("Tremor.pdf"));
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(),"Hello","javascript:alert('ok');",true);
                }
            }
            catch { }
    }

I debug this code When it reached to path that I have given above i.e. "~\\Reports\\Tremor.rdlc" it reaches to catch and throws exception Load Report failed
Please Guide me
Posted
Updated 25-Nov-11 21:01pm
v2
Comments
thatraja 26-Nov-11 21:16pm    
Handle the exception & give us the error message. Let me know once you updated the message. Use reply link on this comment to reply me.

1 solution

Check out the following link :

Custom code in SSRS
 
Share this answer
 

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