views:

20

answers:

2

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?

A: 

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.

Henk Holterman
Aha, excellent. Much obliged.
Raven Dreamer
+1  A: 

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

Hans Passant