ASP.NET MVC, MVC, C#, PYTHON, JQUERY

Friday, July 3, 2020

Insert,Update and Delete Using Asp.net MVC



 In this article, we will learn about how to Insert, Update and Delete Records in ASP.NET MVC 5.

LET'S START ASP.NET MVC 5 WITH 

 In this example, I am going to create a simple student registration form in MVC5 using CRUD  (Create, Read, Update and Delete) Operation. In this tutorial, We will use  entity framework.

 <pre>
 <code class="csharp">
public List<RecruitmentRegistrationModel> GetUserRegistrationRecord(RecruitmentRegistrationModel model, int ProcId)
        {
            var sqlParam = new SqlParameter[]{
                          new SqlParameter { ParameterName = "@ProcId" , Value =ProcId },
                          new SqlParameter { ParameterName = "@Id" , Value =model.ApplicationPostId },
                          new SqlParameter { ParameterName = "@Gender" , Value =model.Gender??"" },
                          new SqlParameter { ParameterName = "@Age" , Value =model.Age??0 },
                          new SqlParameter { ParameterName = "@TotalExp" , Value =model.TotalExp??0 },
                          new SqlParameter { ParameterName = "@EmployerType" , Value =model.EmployerType??"" }
                    };
            var sqlQuery = @"proc_GetUserRegistrationRecord @ProcId,@Id,@Gender,@Age,@TotalExp,@EmployerType";
            var res = this.Database.SqlQuery<RecruitmentRegistrationModel>(sqlQuery, sqlParam).ToList();
            return res;
        }
                               </code></pre>





Share:

0 comments:

Post a Comment

SOCIAL PROFILES

Search This Blog

Powered by Blogger.

Fixed Menu (yes/no)

yes

Contact Form

Name

Email *

Message *

Tags

Ads Section

Tags

ASP.NET MVC (7) C# (11) jQuery (1)