简体   繁体   English

每次我运行Visual Studio C#应用程序时,Access 2007中的所有记录都会删除

[英]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.

相关问题 如何使用Visual Studio在C#应用程序中发布Access数据库? - How do I publish an Access database with my C# application using Visual Studio? Visual C#和Microsoft Access 2007 - Visual C# And Microsoft Access 2007 当我运行我的 C# 应用程序时,Visual Studio 报告它已经加载了一个托管二进制文件(看起来像)一个随机生成的名称 - When I run my C# application, Visual Studio reports that it has loaded a managed binary with (what looks like) a randomly generated name 花费太长时间使用C#WPF应用程序Visual Studio写入Access数据库 - Take too long time to write in to Access Data Base using C# WPF application, Visual Studio, 如何使用Visual Studio开发可在所有Windows OS XP,Vista,7、8上运行的C#应用​​程序 - How to develop c# application using visual studio which will run on all windows OS xp,vista,7,8 我用C#开发了一个应用程序,是否可以在没有SQL Server和Visual Studio的另一台PC上运行该应用程序 - I developed an application in C#, is it possible to run this application on another PC which has no SQL Server and Visual Studio Office 2007 Web组件和Microsoft Office电子表格12.0在Visual Studio C#Windows应用程序中的使用 - Office 2007 Web components and Microsoft Office spreadsheet 12.0 usage in Visual Studio C# Windows Application Visual Studio C#单元测试-报告每次运行的结果 - Visual Studio C# unit testing - report results for each run 如何从Visual Studio 2012导出C#应用程序以在其他计算机上运行? - how can I export a C# application from Visual Studio 2012 to run in other computers? 我想访问visual studio命令propmt并使用C#代码运行.bat文件 - I want to access visual studio command propmt and run a .bat file using C# code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM