如何更新TableAdapter? [英] How to update with TableAdapter?
问题描述
我正在使用 WindowsApplication
编写一个使用数据库的程序。
我用 DataGridView
显示数据库值。
目前,我希望通过 DataGridView
更新数据库,因此我写了这段代码:
I'm writing a program in WindowsApplication
which use database.
I display the database values with DataGridView
.
Currently, I want that there would be a possibility to update the database through the DataGridView
, therefore I wrote this code:
private void MainForm_Load(object sender, EventArgs e)
{
// TODO: This line of code loads data into the 'databaseDataSet1.products' table. You can move, or remove it, as needed.
this.productsTableAdapter1.Fill(this.databaseDataSet1.products);
}
private void upButton1_Click(object sender, EventArgs e)
{
this.productsTableAdapter1.Update(this.databaseDataSet1.products);
MessageBox.Show("הנתונים עודכנו בהצלחה!");
}
问题是数据库中没有更新值。
如果有人可以帮助我解决这个问题,甚至更好的解释如何使用 DataGridView
,因为我没有找到任何有用的东西,我会很高兴
The problem is that there is no update of the values into the database.
I'll be happy if someone could help me solve this problem, or even better, explain how to work with DataGridView
, because I haven't found anything useful on the internet.
推荐答案
应该将datagridview绑定到DataTable或BindingList对象,因为它们是可观察的。
You should bind the datagridview to DataTable or BindingList object because they are observable.
这篇关于如何更新TableAdapter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!