Execute Stored Procedure and display result in View using AngularJS in ASP.Net MVC

Last Reply 9 months ago By dharmendr

Posted 9 months ago


I have one stored procedure 

CREATE PROCEDURE [dbo].[PayProcess] 
    -- Add the parameters for the stored procedure here
    (@Date Date)
    SELECT 'Procedure Run sucessfully' As 'Procedure'

After exccuting stored procedure i am getting o.p like below in sql


Procedure Run successfully

After that display the result in View

Note: If I try to execute normal query it was generating result

but if i try to use stored procudure not getting any result

    public JsonResult PayProcess(DateTime date)
        // Call your Procedure. 
            string result = db.GetPayProcess(date).FirstOrDefault();
            //string result = "select * from Report where Id=2";
            //var result = db.GetPayProcess(date).ToString();
            SqlConnection con = new SqlConnection();
            string connectionstring = ConfigurationManager.ConnectionStrings["CMSR"].ConnectionString;
            con.ConnectionString = connectionstring;
            SqlCommand cmd;
            DataTable dtDet = new DataTable();
            SqlDataAdapter sdaDet = new SqlDataAdapter();
            cmd = new SqlCommand(result, con);
            sdaDet.SelectCommand = cmd;
            dtDet = new DataTable();
            List<Dictionary<string, object>> lstReport = GetTableRows(dtDet);
            return Json(lstReport, JsonRequestBehavior.AllowGet);
        catch (Exception ex)
            return Json(ex.Message, JsonRequestBehavior.AllowGet);
    public List<Dictionary<string, object>> GetTableRows(DataTable dtData)
        List<Dictionary<string, object>>
        lstRows = new List<Dictionary<string, object>>();
        Dictionary<string, object> dictRow = null;
        foreach (DataRow dr in dtData.Rows)
            dictRow = new Dictionary<string, object>();
            foreach (DataColumn col in dtData.Columns)
                dictRow.Add(col.ColumnName, dr[col]);
        return lstRows;


This question does not have replies that have been liked.