绑定导航器不保存更改 [英] Binding Navigator not saving changes

查看:57
本文介绍了绑定导航器不保存更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了BindingNavigator上的保存按钮没有将更改提交到数据库的问题。 我在几个项目中尝试过它。 我创建了一个带有"客户"的MS Access数据库。 table,FName和LName。  (我有
尝试了.mdb和.accdb)。 设置数据源并成功测试。 拉入Customer表,将其设置为详细信息(DGV也不起作用),将其拖到form1上并尝试编辑或添加新记录。 显示它,按下保存按钮,
关闭应用程序,当我回来时,更改不存在。

I am having problems with the save button on the BindingNavigator not committing the changes to the database.  I have tried it in several projects.  I make a MS Access database with a "Customers" table, FName and LName.  (I have tried both .mdb and .accdb).  Setup up the data source and test successfully.  Pull in the Customer table, set it to details (DGV doesn't work either), drag it onto form1 and try to edit or add new record.  Shows it does, hit the save button, close the application and the change is not there when I come back.

这应该很简单。 我终于回去尝试了开发者网络示例:

This should be simple.  I finally went back and tried the Developer network example:

" msdn.Microsoft.com/en-us/library/0f92s97z"

"msdn.Microsoft.com/en-us/library/0f92s97z"

即使它没有提交我的更改。 我没有收到任何错误,它显示"更新成功"消息框。 以下是保存按钮点击的代码:

Even it does not commit my changes.  I am not getting any errors and it shows the "update successful" message box.  Here is the code from the save button click:

Try 
    Me.Validate()
    Me.CustomersBindingSource.EndEdit()
    Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers)
    MsgBox("Update successful")

Catch ex As Exception
    MsgBox("Update failed")
End Try




任何想法?


Any idea's?

谢谢。

推荐答案

你好,

选择项目中的数据库,选择"复制到输出目录",它应设置为"如果更新则复制"。为了你。通常它被设置为"始终复制"。这将消除每个版本的更改。

Select the database in the project, select "Copy to Output Directory", it should be set to "Copy if newer" for you. Normally it's set to "Copy always" which will wipe out changes on each build.

另请参阅我的
MSDN文章/代码示例


这篇关于绑定导航器不保存更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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