Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

Dataset not committing to database.

$
0
0

Hello

I'm trying to create my first database. You can find my initial post here:

http://social.msdn.microsoft.com/Forums/windows/en-US/fd40a391-2b5a-4564-bc66-4d1592f18bfe/visual-studio-database-question

I'm operating on a Windows 7 pc, using VS 2012 express and working with VB. I've worked out some of that on my on. I've currently been able to start a new program, add a main form, add a service based database, create a table called AuthorTable in that database, connect to that datasource, and drag and drop it onto my form. I started with data grid view, but I've moved to just dragging my author last name (ASur), author first name (AFirst), and their website if they have one (ASite) to the form. I left out the primary key since the user doesn't need to see that.

Currently, I'm using the buttons that VS puts on there automatically. I was able to open my program and affect the items in database. I could add, delete, and save. It would show that the changes took by changing the number of items in the database. However, it wouldn't reflect the changes when I stopped and restarted the program or when I went to the table in the database explorer and choose to 'show table data'.

After reading this post:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/21ee9897-55f4-4431-bcc5-fd7e65a51b3b/help-saving-dataset-changes-to-a-database?prof=required

I tried clicking on the BooksDatabase.mdf in the solution explorer. Then in the properties window I changed the 'Copy Content to Directory' from 'Copy Always' to 'Copy if Newer'. There is also an option to 'Copy Never'. I don't really understand what those are if someone could explain it.

However, after changing it to 'Copy if Newer' it started to save the changes between runs. I could start the program, make changes, shut it down, and restart it with the changes persisting. If I refreshed the database in the database explorer, though, it reset it to what it looked like when I initially created it and added some items to test it. After rereading the post I mentioned above, that person thought that what was happening with them was that the database in the database explorer was actually the one in the root directory of their project folder and that it was saving to the one in the bin/debug folder, so that with every refresh, it was refreshing to a bad database. I believe that's what's happening with me and I hope it has an easy fix. Should I delete the database from the database explorer and somehow relink to the one in the bin/debug so that it refreshes from the one accepting the changes. Also, should I leave my option set to 'Copy if Newer' or change it to 'Copy Never'? Thanks for the help.


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>