Wednesday, February 17, 2010 2:13 PMDavid,
i don't know how you have the app setup but it sounds like a common issue with the way the database is handled by default. there are two database files that are being worked with here. in the designer or IDE you work with the database in the main application folder. when you debug the database is copied to the debug directory. this can be changed using the database file - copy to output directory - setting. it most likely is set to copy always, this will copy over the database in the debug directory every time and so you lose any changes. do not copy or never copy (forgot the name) will not copy at all. copy if newer will only copy if the file is a newer version such as if you make a change to it.
typically you might use copy if newer but you may want to go without copying it over and work directly with a file in a set directory for testing. you would need to adjust your connection string for this for testing and then set it back when ready to deploy the application.
it can be confusing with the default at times because you make changes in the designer to one file and then you run and it copies over what you changed using your application. so you start to think that your application does not work. this is such an awkward annoying thing but as far a i know it was intended to help you deploy a clean database file with your finished application.
- Marked As Answer by Martin_XieModerator Tuesday, February 23, 2010 10:30 AM
Thursday, February 18, 2010 3:34 PMThanks. My program seems to be working (today). I was able to change the path for the database in the Server Explore to point to the actual database in the bin/debug folder, eventhough the dataset still points to the parent folder of the bin/debug folders. But, it works for now. I wasn't able to figure out the Copy Again, thank you.
Thursday, February 18, 2010 7:56 PMDavid,
something else you can do is:
leave your connection as is
run or build the application one time
then set the copy to output directory setting to "do not copy" by right clicking on the database file and click properties
then when you need to run the program just use the build option from the project menu (i believe). now the project will build any changes you have made and you can go directly to the bin/debug folder of the application and run it from there.
the only thing you need to be careful about with this is you will not be debugging, so it will not hit any breakpoints, etc...
another thing to make it simple sometimes is to just create a little subroutine to place test data into database on each buiild. but, copy if newer still is an easy option if you still need to make changes to the database while testing.
i know all this can be confusing, you just have to play with it and get a feel for what all is happening.
when i work with sql server express i might just use sql server management studio express to create and change the database. i leave it attached to the server software and point my connection string there. makes it a little easier sometimes for me.
well, hope this helps and does not add any more confusion.