在Visual Studio中运行应用程序时,Access数据库的更改不会持久 [英] Changes to Access database do not persist when running app in Visual Studio

查看:119
本文介绍了在Visual Studio中运行应用程序时,Access数据库的更改不会持久的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Visual Studio 2010 Professional和Access 2010中创建一个库应用程序。我将Access数据库绑定到Visual Studio。当我填写字段并单击提交时,我可以看到DataGridView中的新记录,但是当我关闭应用程序时,新记录不会被保存,我必须再次输入记录。

I am creating a library application in Visual Studio 2010 Professional and Access 2010. I bind the Access database to Visual Studio. When I fill out the fields and click submit I can see the new record in the DataGridView, but when I close the application the new record is not saved and I have to input the record again.

有人帮我知道为什么当我通过应用程序输入新记录时,记录不会保存在数据库中?

Can somebody help me to know why when I input the new record through the application the record is not saved in the database?

推荐答案

这是一个很常见的情况。您的数据库文件(MDB或ACCDB文件)列在您的项目项之间。如果您单击此文件并查看属性窗口,您将看到一个名为的属性复制到输出目录。如果此属性设置为复制始终,则每次启动调试会话时,项目项目中列出的数据库文件将由VS在输出目录中复制(通常为BIN\ DEBUG)。当然这个副本不包含上次调试会话中插入的记录,并且认为您以前的插入失败。

It is a very common situation. You have your database file (the MDB or ACCDB file) listed between your project items. If you click on this file and look at the properties window you will see a property called Copy to the output directory. If this property is set to Copy Always then every time you start a debug session the database file listed in your project items is copied by VS in the output directory (usually BIN\DEBUG). Of course this copy doesn't contain the records inserted in your last debug session and you think that your previous insert has failed.

将此属性设置为复制如果较新的,只有手动更改数据库模式,才会发生上述的行为。

Setting this property to Copy If Newer, the mentioned behavior will happen only if you change the database schema manually.

将此属性设置为从不复制,将允许您手动复制数据库文件。

Setting this property to Copy Never, will let you manually copy the database file.

这篇关于在Visual Studio中运行应用程序时,Access数据库的更改不会持久的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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