You must Sign In to post a response.
  • Category: .NET

    About crud operation mvc with class library

    How can i update a record in mvc with class library in real time scenario

    Like-: webproject.BLL
    webproject.BOL
    webproject.DAL
    webproject.web
  • #769065
    Hai Prasanta Kumar Bisoyi,
    The use of class library is same in any application whether the application is developed using windows, web, mobile or any other applications like console, or any service using Web Service or WCF service. In all the cases, the uses of the class library is same.
    So if you are talking about to use in MVC, you need to first get dll and then by adding the reference, you can use it. Once you add the reference to the project, you can call the methods, properties etc for the dll. The dll should contains the logic required for the CRUD operations and it will be called from controller.
    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com

  • #769108
    You need create methods to handle the CRUD operation and use code snippet as given here
     namespace CRUDUsingMVC.Repository
    {
    public class ExampleRepository
    {

    private SqlConnection con;
    private void connection()
    {
    string constr = ConfigurationManager.ConnectionStrings["getconn"].ToString();
    con = new SqlConnection(constr);

    }
    public bool AddEmployee(EmpModel obj)
    {

    connection();
    SqlCommand com = new SqlCommand("AddNewEmpDetails", con);
    com.CommandType = CommandType.StoredProcedure;
    com.Parameters.AddWithValue("@Name", obj.Name);

    con.Open();
    int i = com.ExecuteNonQuery();
    con.Close();
    if (i >= 1)
    {

    return true;

    }
    else
    {

    return false;
    }


Sign In to post your comments