Avatar of jjliu4492
jjliu4492

asked on 

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

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);

                dgTime.AutoResizeColumns();

Open in new window

TimeEntryScreen.png
C#Microsoft SQL Server 2008

Avatar of undefined
Last Comment
jjliu4492

8/22/2022 - Mon