问题描述
我想作一个简单的数据输入应用程序。所以,我做了以下
i wanted to make a simple data entry application. So i did the following
- 创建一个新的Windows窗体应用程序
- 新增一个DataGridView
- 增加了一个新的数据源(SQL Express数据库,有3列一个表 - ID,姓名,号码)ID是整数,是主键
- 作为设计师自动填充DataSet中,的BindingSource和TableAdapter的我跑的应用程序。
- Created a new Windows Form Application
- Added a DataGridView
- Added a new DataSource (SQL Express Database, having a single table with 3 columns - id, name, number) id is integer and is the primary key
- As the designer automatically populates the DataSet, BindingSource and TableAdapter i ran the application.
当我跑这表明现有的数据应用,我能够通过单击空行来添加新数据或编辑现有数据。但是,这并不存储(提交)数据给我。
when i ran the application it showed the existing data, and i was able to add new data by clicking on empty row or edit existing data. But it did not store (commit) the data for me.
在我做出改变,我只是关闭应用程序。我记得做它前一段时间,它用来反映更改。我一定要添加任何代码提交修改?
After i make the changes i just close the application. I remember doing it some time ago and it used to reflect changes. Do i have to add any code to commit the changes?
推荐答案
一个数据集(定义)断开。如果您要提交新的数据/更新/删除(等),你将有权要求适配器保存更改。如果你已经有一个生成的适配器,这应该是约1行额外的代码...(的适配器上,通常是通过保存按钮的点击
处理)。
A dataset is (by definition) disconnected. If you want to commit new data / updates / deletes (etc), you are going to have to ask the adapter to save the changes. If you already have a generated adapter, this should be about 1 line of extra code... (Update
on the adapter, usually via a save button's Click
handler).
这篇关于无法使用datagridview的使用C#中的WinForms添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!