BindingSource and tableAdapter changes not commiting to the database - C#, Visual Studio 2013

纵然是瞬间 提交于 2019-12-12 05:37:20

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!