如何使用 TableAdapter 进行更新?

How to update with TableAdapter?(如何使用 TableAdapter 进行更新?)
本文介绍了如何使用 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.

推荐答案

        this.Validate();
        this.productsBindingSource.EndEdit();
        this.productsTableAdapter1.Update(this.databaseDataSet1.products);
        //this.productsTableAdapter1.UpdateAll(this.databaseDataSet1);

这篇关于如何使用 TableAdapter 进行更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)