数据库未更新 [英] Database isn't updating
问题描述
我试图写一些数据到一个.MDF数据库,只有一个表,它不会更新我执行这部分代码后:
I am trying to write some data into a .MDF database that has only one table, and it's not updating after I execute this part of the code:
DatabaseDataSet.MyTableRow newRow;
newRow = databaseDataSet.MyTable.NewMyTableRow();
newRow.name = "x";
newRow.level = 100;
newRow.health = 100;
newRow.weapon = "club";
this.databaseDataSet.MyTable.Rows.Add(newRow);
int result = MyTableTableAdapter.Update(databaseDataSet.MyTable);
MessageBox.Show(result.ToString());
我是使用C#中的SQL数据库的新人。
I am new to working with SQL databases in C#.
我使用 TableAdapter.Update
来更新数据库中的 MyTable
表,我甚至尝试编写我自己的查询版本的Update,我也尝试了 MyTableAdapter.insert
函数...没有结果。
I'm using TableAdapter.Update
to update the MyTable
table in the database, I even tried writing my own query version of Update, and I also tried with the MyTableAdapter.insert
function...and no results. I can successfully read data from a database, but when it comes to writing, I fail hard.
推荐答案
更新(插入和删除)我可以从数据库中成功读取数据, )只会修改表适配器的本地客户端视图,你必须SaveChanges才能将其提交到数据库。
Update (insert and delete) will only modify the local client view of the table adapter, you have to SaveChanges in order to commit it to the database.
这篇关于数据库未更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!