How to save changes from a datagridview to a SQL Server 2008 database using Linq to SQl

Posted on 2011-10-06
Last Modified: 2012-08-14
I have a VS 2010 windows form application, where the user can edit/add new rows into a datagridview. I use Linq to SQL to populate the datagridview with the existing data from the database. My question is when the user clicks on the Save button, how do I write the changes and/or new data entered back to the database, using Linq to SQL?

Below is the c# code I use to populate the datagridview.
OperationsDataContext opDC = new OperationsDataContext();

                dgTime.DataSource = opDC.Tasks_GetByProjectIDAndWeekEndingDate(Convert.ToInt32(cboTimeProject.SelectedValue), dtWeekEnding.Value);


Open in new window

Question by:jjliu4492
    LVL 26

    Expert Comment

    by:Anurag Thakur

    Accepted Solution


    Author Closing Comment

    I found the solution using google.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now