从WPF应用程序更新Access数据库不起作用 [英] Updating Access databases from a WPF application not working

查看:126
本文介绍了从WPF应用程序更新Access数据库不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我已经使用WPF构建了一个小型应用程序来访问Access数据库.我将Access数据库添加为数据源,并绑定了所有必需的控件等.它可以很好地显示数据:),但是对于我来说,我无法弄清楚为什么它不更新任何数据. :mad:
所有的指示都很好,没有应用程序或系统错误消息,甚至DataTable对象似乎都正常,数据已更新等,但是当我在当前数据行上发出AcceptChanges命令时……在后端没有任何反应.关于为什么什么都不会发生的唯一线索是DataRow.Row.RowState值从不更改,它始终是未修改的".我不知道为什么.
任何帮助将不胜感激.

感谢您一直以来的帮助.通过进一步的说明,我创建了一个WPF表单应用程序,并添加了一个表数据源.我添加了一个列表框,并将文本框从数据源中所需的列拖动到表单的工作表面.然后,我为列表框添加了绑定,以使其指向表,为文本框添加了指向列表中当前项的绑定,并为保存逻辑添加了一个按钮.最后,我将AcceptChanges逻辑添加到Save按钮click事件中,并将BeginEdit逻辑包括在列表框的SelectionChanged事件中.
我尽可能地保持它的简单,并且得到的结果完全相同,即使应用程序正在运行时,文本框中的更改也不会传播到表中.即使它们似乎已更改.

Hello,
I have built a small application using WPF to front end an Access database. I added the Access database as a datasource and bound all the necessary controls etc etc. It works fine to display the data :), but for the life of me I cannot figure out why it will not update any data. :mad:
All the indications are fine, no app or system error messages, even the DataTable objects seem OK, data is updated etc but when I issue the AcceptChanges command on the current datarow.... nothing happens on the back end. THe only clue that I have about why nothing happens is the DataRow.Row.RowState value never changes, it is always "unmodified". I don''t know why that is.
Any help would be much appreciated.

Thanks for your help so far. By way of further explaination I created a single WPF form application and added a single table data source. I added a listbox and dragged a textbox from the column I wanted in the data source, to the work surface for the form. Then I added the bindings for listbox to point to the table, and the textbox to point to the current item in the listbox, and added a button for the save logic. Finally I added the AcceptChanges logic to the Save button click event and included the BeginEdit logic in the SelectionChanged event of the listbox.
I kept it as simple as I possibly could, and I get exactly the same result, changes in the textbox are never propogated to the table, even though they appear to be changed while the application is running.

推荐答案

此行为听起来像您可能有一个未提交的未清事务.在提交事务之前,更改不会出现.您的代码中有这种可能吗?可能是外部"事务(一个由堆栈中较高级别的代码打开的事务)阻止了更改的持久化.
This behavior sounds like you might have an Open, uncommitted transaction. Changes will not appear until you Commit the transaction. Is this a possibility in your code? It''s possible that an "outer" transaction (one Opened by some code higher on the stack) is preventing the changes from being persisted.


这篇关于从WPF应用程序更新Access数据库不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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