问题
I've seen a lot of problems that are closely related to this but haven't found a solution, so I'm asking. I created a insert into query using the wizard and the tableAdapter that is automatically generated when you drag and drop the datasource into your Windows form. When I put all my data(is a sign up screen) and push sign up, the tableAdapter does the update with the following commands:
this.userTableAdapter.InsertQuery(loginText.Text.Trim(), nameText.Text.Trim(), int.Parse(ageText.Text), trackBar1.Value, trackBar2.Value, trackBar3.Value, passwordText.Text.Trim(), false, sex.Text.Trim());
try
{
//this.Validate();
//this.userBindingSource.EndEdit();
this.userTableAdapter.Update(this.databaseJogoDataSet.user);
MessageBox.Show("UPDATED!!!");
}
catch (System.Exception ex)
{
MessageBox.Show("Update Failed");
}
The "UPDATED!!!" messagebox is shown and the login starts to work with the new data, but once I close the program these new datum is wiped from the database. How can I commit the changes I did and permanently write them to the DB?
Thanks.
来源:https://stackoverflow.com/questions/28051351/bindingsource-and-tableadapter-changes-not-commiting-to-the-database-c-visua