carpenoctem112
02-22-07, 09:25 PM
Firstly, let me say I used to use this forum a while ago and I guess I forgot my login / password, so I had to make a new account.
now on to the problem.
I'm using several datagrids to access different tables in a database, I have basically everything working except I can't find out for the life of me what I'm doing wrong in the update method.
This is exactly what I'm doing to update my datagrid (minus error checking)
DataSet mychangedDs = this.cafeDataSet.GetChanges();
if (mychangedDs != null)
{
//get # of rows changes
int modifiedRows = this.pearlTableAdapter.Update(cafeDataSet);
MessageBox.Show("Database has been updated successfully: " +
modifiedRows + " Modified row(s) ", "Success");
this.cafeDataSet.AcceptChanges();
//refresh dataset
this.cafeDataSet.Clear();
pearlTableAdapter.Fill(cafeDataSet.Pearl);
pearlData.DataSource = cafeDataSet.Tables["pearl"].DefaultView;
}
else
{
MessageBox.Show("Nothing to save", "No changes");
}
Any help would be greatly appreciated.
P.S. - Wasn't there a "programming" forum before?
edit: the message box does appear with the correct message, and the datagrid refreshes with the changes, but when I restart the program, all the changes are gone (and not in the database either)
now on to the problem.
I'm using several datagrids to access different tables in a database, I have basically everything working except I can't find out for the life of me what I'm doing wrong in the update method.
This is exactly what I'm doing to update my datagrid (minus error checking)
DataSet mychangedDs = this.cafeDataSet.GetChanges();
if (mychangedDs != null)
{
//get # of rows changes
int modifiedRows = this.pearlTableAdapter.Update(cafeDataSet);
MessageBox.Show("Database has been updated successfully: " +
modifiedRows + " Modified row(s) ", "Success");
this.cafeDataSet.AcceptChanges();
//refresh dataset
this.cafeDataSet.Clear();
pearlTableAdapter.Fill(cafeDataSet.Pearl);
pearlData.DataSource = cafeDataSet.Tables["pearl"].DefaultView;
}
else
{
MessageBox.Show("Nothing to save", "No changes");
}
Any help would be greatly appreciated.
P.S. - Wasn't there a "programming" forum before?
edit: the message box does appear with the correct message, and the datagrid refreshes with the changes, but when I restart the program, all the changes are gone (and not in the database either)