重建 .SLN 时回滚数据库更改 (VS2008)

发布于 2024-09-07 13:02:17 字数 516 浏览 0 评论 0原文

所以,各位。这里发生了一件有趣的事情。

我有一个在 VS2008 中制作的 Windows 窗体应用程序,直到最近,它一直连接到 SQL Server 2008 数据库。我能够编辑、插入、删除或选择数据库中的任何各种表,并且提交更改 - 每次我通过 SQL 查询对数据库进行更改时,该更改都会反映在数据库中。

然而,在过去的几天里,我已将数据库文件导入到 VS studio .SLN 中,并将数据集的数量从 3 个减少到 1 个(为了方便起见,将不同的表组合在一起),现在,我对数据库不会提交。

我观察到以下行为:

1)从表中插入或删除记录没有被提交——下次运行程序时,删除的记录又回来了,并且任何插入的记录都消失了。以前,插入和删除似乎在运行时提交更改。

2)使用 UPDATE 命令手动提交更改是有效的 - 添加的记录保留,删除的记录保持消失,但是...

3)如果我出于某种原因重建解决方案,数据库将“重置”到我第一次时的状态更改了数据库的位置。

有谁知道我现在所做的不同做法会造成这种行为吗?

So, folks. Got an interesting occurrence going on here.

I have a windows forms application made in VS2008 which has, up until recently, been connecting to a SQL Server 2008 database. I was able to edit, insert, delete, or select any of the various tables within the database, and the changes were commited -- each time I made a change to the database via SQL queries, that change was reflected within the database.

Within the last few days, however, I have imported the database file into the VS studio .SLN, and brought my number of datasets down from three to one (combining the disparate tables for convenience), and now -- changes I make to the database won't commit.

I have observed the following behavior:

1) Inserting or Deleting records from a table is not getting committed -- the next time I run my program, deleted records are back, and any inserted records are gone. Previously, Insert and Delete seemed to commit changes when they ran.

2) Using an UPDATE command to manually commit changes works -- added records remain, and deleted records stay gone, but...

3) If I rebuild the solution for whatever reason, the database "resets" to what it was when I first changed the location of the database.

Does anyone have an idea as to what I'm doing differently now that would create this type of behavior?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

清风夜微凉 2024-09-14 13:02:17

在“解决方案资源管理器”窗口中选择 .mdf。在“属性”窗口中,将“复制到输出目录”更改为“如果较新则复制”。

Select the .mdf in the Solution Explorer window. In the Properties window, change Copy to Output Directory to "Copy if newer".

剑心龙吟 2024-09-14 13:02:17

我已将数据库文件导入到
VS 工作室.SLN

在你的项目文件夹中仔细查看。您可能会在项目的根目录中找到一个 .MDF 文件,并在 Bin/Debug 中找到另一个文件(工作副本)。在每次(重新)构建时,工作副本都会被覆盖。

换句话说,这是设计使然。

I have imported the database file into
the VS studio .SLN

Look closely in your project folder. You probably will find a .MDF file in the root of your project and another one (working copy) in Bin/Debug. On each (Re)Build the working copy is overwritten.

In other words, it's by design.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文