G
Guest
I am trying to enter a new row into a test database and have been
unsuccessful. The code compiles fine and runs with out runtime errors,
however after closing the form and checking the database it is the same.
Since this is my first time using a database any additional suggestions that
I should check on that are not obvious in my code snippet will be useful!
Sincere thanks,
Rock
private void button1_Click(object sender, EventArgs e)
{
// Create new entry
myDatabaseDataSet.UserNamesRow user =
myDatabaseDataSet.UserNames.NewUserNamesRow();
user.First = firstTextBox.Text;
user.Last = lastTextBox.Text;
myDatabaseDataSet.UserNames.Rows.Add(user);
// Save new entry
this.Validate();
this.userNamesBindingSource.EndEdit();
if(user.RowState != DataRowState.Added)
MessageBox.Show("No Changes Seen in DataSEt");
int result =
this.userNamesTableAdapter.Update(this.myDatabaseDataSet.UserNames);
//Display # of updated rows
MessageBox.Show(result.ToString());
}
unsuccessful. The code compiles fine and runs with out runtime errors,
however after closing the form and checking the database it is the same.
Since this is my first time using a database any additional suggestions that
I should check on that are not obvious in my code snippet will be useful!
Sincere thanks,
Rock
private void button1_Click(object sender, EventArgs e)
{
// Create new entry
myDatabaseDataSet.UserNamesRow user =
myDatabaseDataSet.UserNames.NewUserNamesRow();
user.First = firstTextBox.Text;
user.Last = lastTextBox.Text;
myDatabaseDataSet.UserNames.Rows.Add(user);
// Save new entry
this.Validate();
this.userNamesBindingSource.EndEdit();
if(user.RowState != DataRowState.Added)
MessageBox.Show("No Changes Seen in DataSEt");
int result =
this.userNamesTableAdapter.Update(this.myDatabaseDataSet.UserNames);
//Display # of updated rows
MessageBox.Show(result.ToString());
}