调用 DataAdapter.Update 时,DataSet 仅进行一项 DataGridView 更改
我使用 DataGridView 中的 CellEndEdit 事件来检测用户何时完成单元格编辑。我想将结果发布回数据库。 datagridview 绑定到 DataView。我保留了用于填充数据集的原始 DataAdapter (SQLDataAdapter),从而将数据显示给用户。所有更新和选择命令都是在我最初创建适配器时定义的。此外,当用户对 datagridview 中的单元格进行初始更新时,更新会发布到数据库。但后续更新不再发布。就好像行状态仍然显示不变。我所做的就是调用 DataAdapter.Update(myDataSet, "TABLE");
我需要在某处重置某些东西吗?
谢谢
I am using the CellEndEdit event in DataGridView to detect when a user has finished editing a cell. I want to post the results back to the database. The datagridview is bound to a DataView. I retain the original DataAdapter (SQLDataAdapter) used to fill the dataset and thus display the data to the user. All update and select commands are defined when I create the adapter initially. Also, when a user makes one initial update to a cell in the datagridview, the update posts to the database. However, subsequent updates do not post. It is as if the row state is still showing unchanged. All I am doing is calling DataAdapter.Update(myDataSet, "TABLE");
Do I need to reset something somewhere?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,如果您将 DataAdapter.Update 代码放入 datagridview 的 CellEndEdit 事件中,它将不起作用。因此,我添加了一个带有 Click 事件的菜单项,并将更新代码粘贴到那里。效果很好。 CellEndEdit 不起作用肯定有一些根本原因,但我现在不知道为什么。
Apparently it won't work if you put the DataAdapter.Update code in the CellEndEdit event for the datagridview. So, I added a menu item with a Click event and pasted the Update code there. It works great. There must be some underlying reason why CellEndEdit will not work, but I do not know why at the moment.