问题描述
我创建使用Microsoft Visual Studio .NET 2008我使用的是.sdf文件作为我的数据库中的桌面应用程序。我的问题是,当我更改为我的记录(新增,删除,更新),那么变化仅反映,而我的应用程序运行。当我重新启动应用程序,然后我没有得到我的变化。
I am creating a Desktop application using Microsoft Visual Studio .NET 2008. I am using a .sdf file as my database. My problem is that when I am making changes to my records (add new, deleted, updated) then the changes reflects only while my application is running. When I restart the application then I am not getting my changes.
我使用的是默认的连接字符串
I am using the default connection string
string conString = Properties.Settings.Default.DataConnectionString;
SqlCeConnection con = new SqlCeConnection(conString);
con.Open();
由Visual Studio该数据库中给出的值是
The value given by Visual Studio for this database is
数据源= | DataDirectory目录| \Data.sdf
我不知道什么错误我做的,但所有的查询执行。
I don't know what mistake I am doing, but all the queries are executing.
推荐答案
在VS.NET从每次运行时,它正在复制从溶液中SDF文件到您的bin文件夹,并覆盖这是有从上次运行的bin / SDF文件。更改您的SDF文件的属性为复制,如果新,而不是复制总是。
Every time you run from VS.NET, it is copying the sdf file from the solution into your bin folder, and overwriting the bin/sdf file that was there from the last run. Change your sdf file's properties to "copy if newer" instead of "copy always".
这篇关于数据库文件。自卫队关闭应用程序后不更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!