Click here to Skip to main content
15,885,435 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
C#
private void btnUpdate_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                comocoLTSDataContext dc = new comocoLTSDataContext();
                DCdate dateRow = dataGrid1.SelectedValue as DCdate;
                //int m = dateRow.GKId;
                DCdate date = (from d in dc.DCdates
                               where d.GKId == dateRow.GKId & d.DId==dateRow.DId & d.DCcontainer.ContainerNo==txtContNo.Text
                               select d).Single();
                date.Date1 = dateRow.Date1;
                date.Temp00 = dateRow.Temp00;
                date.Temp06 = dateRow.Temp06;
                date.Temp12 = dateRow.Temp12;
                date.Temp18 = dateRow.Temp18;
                date.DLane = dateRow.DLane;
                date.DVentilation = dateRow.DVentilation;
                date.DRemarks = dateRow.DRemarks;
                dc.SubmitChanges();
                MessageBox.Show("Row Updated Successfully");
                LoadDates();


            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            } 

        }


this is how I tried to update my db using datagridview. code seems to be ok. also giving the "Row updated" message. but when call LoadDates() Db has not been updated.

please help me soon...

why can't anyone give me a reason.....
Posted
Updated 17-Oct-12 4:37am
v5
Comments
[no name] 12-Oct-12 21:26pm    
And that exception would be what?
Akinmade Bond 28-Oct-12 6:02am    
You should Refresh the DataGridView after the 'Row updated' message.

1 solution

I found a good solution from this
http://www.dotnetcurry.com/ShowArticle.aspx?ID=563
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900