Gcobani Mkontwana

Gcobani Mkontwana

  • 560
  • 1.9k
  • 412.2k

CrystalDecisions.Shared.CrystalReportsException

Feb 18 2020 11:18 PM
Hi Mates
 
I am getting an exception to my Load() method, i am using CrystalDecision for reporting. Any one who can help me with this issue?
  1.      [HttpPost]  
  2.         [ValidateAntiForgeryToken]  
  3.         public ActionResult AdvertReport(FormCollection fc)  
  4.         {  
  5.             DataSet ds = obIlReports.Generate_AdvertDetailsReport();  
  6.             ds.Tables[0].TableName = "Tbl_TrainingAcademy";  
  7.   
  8.             if(ds.Tables[0].Rows.Count > 0)  
  9.             {  
  10.                 ReportClass rptH = new ReportClass();  
  11.                 rptH.FileName = Server.MapPath("~/Reports/AdvertReport.rpt");  
  12.                 rptH.Load();  
  13.                 rptH.SetDataSource(ds.Tables[0]);  
  14.                 Response.Buffer = false;  
  15.                 Response.ClearContent();  
  16.                 Response.ClearHeaders();  
  17.   
  18.   
  19.                 Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);  
  20.                 stream.Seek(0, SeekOrigin.Begin);  
  21.                 return File(stream, "application/pdf""AdvertReport.pdf");  
  22.             }  
  23.             return View();  
  24.         }  
  25.     }  
  26.   
  27.   
  28.   
  29.   
  30.     "eNtsaOnlineRegistrationDB" connectionString="Data Source=GcobaniM-L\SQLEXPRESS; DataBase=eNtsaOnlineRegistrationDB; Integrated Security=True" providerName="System.Data.SqlClient" />  
  31.     
  1. //IReport   
  2.   
  3.  public class ReportsMaster : IlReports  
  4.     {  
  5.         public DataSet Generate_AdvertDetailsReport()  
  6.         {  
  7.             using(SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["eNtsaOnlineRegistrationDB"].ToString()))  
  8.             {  
  9.                 con.Open();  
  10.                 DataSet ds = new DataSet();  
  11.   
  12.                 // Handling Exception  
  13.                 try  
  14.                 {  
  15.                     SqlCommand cmd = new SqlCommand("dbo.GetAdvertReport", con);  
  16.                     cmd.CommandType = CommandType.StoredProcedure;  
  17.                     SqlDataAdapter da = new SqlDataAdapter();  
  18.                     da.SelectCommand = cmd;  
  19.                     da.Fill(ds);  
  20.   
  21.                     if(ds.Tables.Count > 0)  
  22.                     {  
  23.                         return ds;  
  24.                     }  
  25.                     else  
  26.                     {  
  27.                         return ds = null;  
  28.                     }  
  29.   
  30.                 }  
  31.                 catch(Exception )  
  32.                 {  
  33.                     throw;  
  34.                 }  
  35.                 finally  
  36.                 {  
  37.                     ds.Dispose();  
  38.                 }  
  39.             }  
  40.         }  
  41.     }  
  42. }  
 

Answers (2)