• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Adding new lines into a Access DB through a Datagrid

Here's the code I am using
try
                  {
                        DataSet changedData = table1.GetChanges(DataRowState.Modified);
                        if (changedData != null)
                        {    
                              table1.Merge(changedData);
                              int numRows = dataAdapter.Update(changedData, "Haves");
                              MessageBox.Show("Database Updated " + numRows + " rows ok","Success");
                              table1.AcceptChanges();
                        }
                        else
                        {    
                              MessageBox.Show("Nothing to Save","No Changes");
                        }
                  }
                  catch (Exception ex)
                  {    
                        MessageBox.Show("Error " + ex.Message);
                        table1.RejectChanges();
                  }

it has no problem chaging data that is already there but if I add information on a new line I get the nothing to save no changes pop up box

Plase help
0
Socrates2k1
Asked:
Socrates2k1
1 Solution
 
abdullah716Commented:
DataRowState.Modified gets you the modified rows.

DataSet changedData = table1.GetChanges(DataRowState.Modified);

Change this to :

DataSet changedData = table1.GetChanges();

and let me know how it goes.
0
 
Socrates2k1Author Commented:
works Good.. no idea why i never tryed it first
good work
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now