Code to call stored procedure RRS feed

  • Question

  • User1527485495 posted
    Greetings all, please I need a code for calling stored procedure in MVC.
    Thanks in anticipation and regards .
    Friday, September 22, 2017 6:46 AM


  • User-1509636757 posted

    You have not specified if you are using ADO.NET or Entity Framework or some other connectivity mechanism or ORM you are using to access database from your application.

    If you are using Entity Framework, then you simply need to create stored procedure in your database and then add that procedure as function in Entity Framework EDMX file. So, you can call it as function with context object. Here is a detailed understanding provided as article with example: ASP.Net MVC: Call Stored Procedure using Entity Framework

    If you are using ADO.NET, then you can call stored procedure by using SQLConnection and SQLCommand objects. Here is an article with example on HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 22, 2017 11:17 AM

All replies