在C#/MSSQL中从视图更新基础表 [英] Updating Underlying Tables from A View in C#/MSSQL

查看:105
本文介绍了在C#/MSSQL中从视图更新基础表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我希望我在这里错过了一些非常简单的事情,希望你们能帮助我.
我正在编写一个连接到本地数据库(基于服务的数据库)的C#应用​​程序,在这个数据库中,我显然有几个表,还有一个视图,显示了三个表的不同部分.
在应用程序本身中,我正在显示(和编辑/更新)一堆DataGridViews中的表.到目前为止,对表的编辑和后续更新都没有问题.但是,在我的一个DataGridViews中,我没有直接访问表,而是显示了上面提到的视图.显示数据库中已经存在的信息没有问题,但是,当我在数据库中编辑数据时,似乎无法更新基础表.我认为这应该相对简单地完成,但是我似乎缺少了一些东西.
我更新所有其他表的方式是:

Hi everybody,
I hope I''m missing something really simple here and hope that you guys can help me out.
I''m writing a C# application that connects to a local database (service-based database), in this database I obviously have several tables and also one view which shows different parts of three tables.
In the application itself I''m showing (and editing/updating) the tables in a bunch of DataGridViews. The editing and subsequent updating of the tables is no problem, so far so good. However in one of my DataGridViews im not accesing a table directly but instead showing the view mentioned above. Displaying the information that is already in the databse is no problem, however when I edit data there, I seem not to be capable of updating the underlying tables. I presume this should be relativly simple to accomplish, but I seem to be missing something.
The way I update all of the other tables would be:

myTableAdapter.Update(myDataSet.MyTable)


推荐答案

如果显示ViewDataGridView被绑定到BindingSource并且BindingSource被绑定到了数据库,它应该自动更新,但是可以通过使用 ^ ]方法.

希望这可以帮助. :)
If the DataGridView displaying the View was bound to a BindingSource and the BindingSource was bound to the Database, it should update automatically but can be prompted to do so by use of the BindingSource.ResetBindings[^] method.

Hope this helps. :)


这篇关于在C#/MSSQL中从视图更新基础表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆