[英]all records in access 2007 deletes each time i run my visual studio c# application
Have som problem with Access 2007, and visual studio 2008 C#. Access 2007和Visual Studio 2008 C#有一些问题。 each time i try to run my program deletes all records in access. 每次我尝试运行程序时,都会删除访问中的所有记录。 the fields are still there but only records disappears!!! 字段仍然在那里,但只有记录消失了!!! conn.accdb exist in my solution explorer with conn.accdb存在于我的解决方案资源管理器中
path : C:\\Documents and Settings\\kizmo\\Dokumenter\\Visual Studio 2008\\Projects\\conn\\conn\\conn.accdb 路径:C:\\ Documents and Settings \\ kizmo \\ Dokumenter \\ Visual Studio 2008 \\ Projects \\ conn \\ conn \\ conn.accdb
Here i have another copy of conn.accdb and this is the one which all records deletes after running...... C:\\Documents and Settings\\kizmo\\Dokumenter\\Visual Studio 2008\\Projects\\conn\\conn\\bin\\Debug 在这里,我有另一个conn.accdb副本,这是所有记录在运行后删除的副本。C:\\ Documents and Settings \\ kizmo \\ Dokumenter \\ Visual Studio 2008 \\ Projects \\ conn \\ conn \\ bin \\ Debug
i am not sure why i have to have 2 exactly samme database file i different directories. 我不确定为什么我必须在不同目录中有2个完全相同的samme数据库文件。
thx 谢谢
Sounds like the database file has been included in your project as "Copy to Output Directory". 听起来数据库文件已作为“复制到输出目录”包含在您的项目中。 Your application is modifying the one in the bin directory, but everytime you compile, your blank database overwrites it. 您的应用程序正在修改bin目录中的应用程序,但是每次编译时,空白数据库都会覆盖它。 In the properties for that file in your project, turn off the "Copy to Output Directory" option. 在项目中该文件的属性中,关闭“复制到输出目录”选项。 (You will then probably have to to change the path to the database.) (然后,您可能必须更改数据库的路径。)
Also note that what you are seeing isn't necessarily bad in development. 还要注意,您所看到的不一定对开发不利。 Your actual application, I'm assuming, will not be using the database in your Visual Studio bin folder, but somewhere else. 我假设您的实际应用程序将不在其他位置使用Visual Studio bin文件夹中的数据库。 Typically you use the ConnectionString node in your app.config to direct this to the correct location. 通常,您在app.config中使用ConnectionString节点将其定向到正确的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.