Update using LINQ to sql

We use the following code to update from the database using LINQ:-

		
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.Linq;

public partial class Insert_LINQ_To_SQL : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //create the object of data context class and pass the connection string
        DataContext dc = new DataContext("Data Source=ISHA-PC;Initial Catalog=TechAltum;Integrated Security=True");

        //create object of class which mapped the table in database
        Class1 cal_data;
       

        //set the where clause for update the data
        cal_data = dc.GetTable<Class1>().Single(res => res.id == 4);

        //add updated data
        cal_data.dept = "changeDept";

       
        dc.GetTable<Class1>();
        dc.SubmitChanges();
      
      
    }
}

		
		

Email Address

For any query you can send mail at info@techaltum.com
Thanks