本地数据库插入不会被存储 [英] Local database inserts not being stored
问题描述
这可能是我的一个愚蠢的错误..但我似乎无法理解。
This is probably a stupid mistake of me.. but I can't seem to understand it.
我创建了一个新的空C#Windows窗体应用程序
I've created a new, empty C# Windows Forms application.
我添加了一个数据库(基于数据集),并有保存在我的解决方案资源管理器中的文件。
I added a Database (Based on a dataset) and have the file stored in my solution explorer.
我添加了一个表测试
与列名称
。
我添加使用新SqlCeCommand的记录(插入测试值('名称'),新的SqlCeConnection(ConfigurationManager.ConnectionStrings [的ConnectionString]的ConnectionString))的ExecuteNonQuery();
不过,我甚至尝试获取相同的数据,这一切完美的作品。
However, I've even tried retrieving the same data and it all works perfectly.
但是,当我停止我的项目,并重建它。所有数据再次去了?
But when I stop my project, and rebuild it.. all data is gone again?
将这种自我修复的时候有没有办法解决这个问题,或者我将开始使用这个项目它是用来干什么(不含500天重建?)
Is there a way to fix this, or will this fix itself when I'll start using this project for what it is intended (Without the 500 rebuilds a day?)
推荐答案
按给出的答案史蒂夫不断复制数据库在现有的一个,这会导致删除所有数据。
The answer given by steve keeps copying the database over the existing one, which results in removing all data.
我已经设法通过把一直拷贝,然后在解决这个问题资源管理器数据库移动到不同的位置,并把它添加到项目中。通过这种方式,数据库将永远不会被覆盖,并且可以在程序中使用!
I've managed to fix this by putting "Copy Always" on, then in the explorer move the database to a different location and add it to the project. This way the database will never be overwritten and can be used in the program!
(然而,这可能会提出一个问题,如果/当我发布项目到另一台计算机)
(However, this will probably raise a issue if/when I publish the project to another computer)
这篇关于本地数据库插入不会被存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!