问题描述
我设置的DataGridView和其他UI组件,允许用户从SQLite的数据库编辑数据。但是,这些变化(即使他们是正确显示了在应用程序)并没有保存到数据库。我曾尝试code
I setup DataGridView and other UI components to allow user to edit data from SQLite DB. But these changes (even they are properly shows in application) doesn't saves to DB. I have tried this code
aBindingSource.EndEdit();
dbDataSetA.GetChanges();
aTableAdapter.Update(dbDataSetA.Accounts);
但也有并发异常:
but there are concurrency exception:
System.Data.DBConcurrencyException是未处理消息=并发 冲突:在更新命令影响0预期1条记录。
所以,我应该怎么提交的BindingSource更改数据库,伙计们?
So how should I commit bindingsource changes to DB, guys?
POST修改我得到这个例外,当我启动该程序,然后单击在DataGridView的第二行,然后在第三,这一次程序提高并发异常。希望他的帮助下得到这个问题的更详细的。
POST EDITI got this exception when I start the program, then click on second row in DataGridView and then on third and this time program raise a concurrency exception. Hope his help get this issue more detailed.
在此先感谢,伙计们!
推荐答案
有一个同样的问题。诀窍是,一旦你更新的表,你应该空getChanges()。你可以通过调用方法acceptChanges()。所以... aBindingSource.EndEdit(); dbDataSetA.GetChanges(); aTableAdapter.Update(dbDataSetA.Accounts); dbDataSetA.AcceptChanges();
Had a same problem. Trick is, once you update table, you should "empty" getChanges(). You do that by calling method AcceptChanges(). So...aBindingSource.EndEdit(); dbDataSetA.GetChanges(); aTableAdapter.Update(dbDataSetA.Accounts); dbDataSetA.AcceptChanges();
应该工作,只要它是同样的问题。
should work, provided it is the same problem.
干杯,牛逼
这篇关于如何正确提交的BindingSource更改源DB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!