Link to home
Create AccountLog in
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
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

ASKER CERTIFIED SOLUTION
Avatar of jjliu4492
jjliu4492

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of jjliu4492
jjliu4492

ASKER

I found the solution using google.