Guest User

Guest User

  • Tech Writer
  • 2.1k
  • 469.6k

Cannot find procedure GetAdvertReport

Feb 18 2020 5:03 AM
Hi Mates
 
I am trying to develop a report as pdf, i get thrown for an error saying "Cannot find the store procedure" . But there is a store procedure on the database table name 'Tbl_TrainingAcademy'. 
  1. // Repository   
  2.   
  3. using System;  
  4. using System.Collections.Generic;  
  5. using System.Linq;  
  6. using System.Data.SqlClient;  
  7. using System.Configuration;  
  8. using System.Web;  
  9. using ContentManagementSystem.Models;  
  10. using System.Data;  
  11.   
  12. namespace ContentManagementSystem.Repository  
  13. {  
  14.     public class ReportsMaster : IlReports  
  15.     {  
  16.         public DataSet Generate_AdvertDetailsReport()  
  17.         {  
  18.             using(SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["eNtsaOnlineRegistrationDB"].ToString()))  
  19.             {  
  20.                 con.Open();  
  21.                 DataSet ds = new DataSet();  
  22.   
  23.                 // Handling Exception  
  24.                 try  
  25.                 {  
  26.                     SqlCommand cmd = new SqlCommand("GetAdvertReport", con);  
  27.                     cmd.CommandType = CommandType.StoredProcedure;  
  28.                     SqlDataAdapter da = new SqlDataAdapter();  
  29.                     da.SelectCommand = cmd;  
  30.                     da.Fill(ds);  
  31.   
  32.                     if(ds.Tables.Count > 0)  
  33.                     {  
  34.                         return ds;  
  35.                     }  
  36.                     else  
  37.                     {  
  38.                         return ds = null;  
  39.                     }  
  40.   
  41.                 }  
  42.                 catch(Exception )  
  43.                 {  
  44.                     throw// Exception states cant find the store procedure 'GetAdvertReport'  
  45.                 }  
  46.                 finally  
  47.                 {  
  48.                     ds.Dispose();  
  49.                 }  
  50.             }  
  51.         }  
  52.     }  
  53. }  
  1. // ConnectionString from Web.config  
  2. <connectionStrings>  
  3.     <add name="eNtsaOnlineRegistrationDB" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\eNtsaOnlineRegistrationDB.mdf;Initial Catalog=eNtsaOnlineRegistrationDB; Integrated Security=True" providerName="System.Data.SqlClient" />  
  4.   </connectionStrings>  
 

Answers (2)