Commiting datagridview Data to the database

MikeMackey

Member
Joined
Aug 28, 2009
Messages
5
Programming Experience
1-3
Hi, I'm new to working with windows forms in this way so please bear with me.

I'm using an VB.net 2008 with an attached 2007 Access database. I have a datagridview that displays one of my tables from the database, with option to edit everything. My code behind is:

VB.NET:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.BirthdayTableAdapter.Fill(Me.BirthdayDataSet.Birthday)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.BirthdayTableAdapter.Update(Me.BirthdayDataSet.Birthday)
    End Sub

Now when I click button 1 it will save the data somewhere, because if I quickly run the program again the changes I made will be there. But if I go to the database to confirm my changes, I will see that nothing has happened, and then if I run the program again all changes will have reverted to the original state.

Any thoughts? Thanks
 
You're simply looking in the wrong place and at the wrong time.
if I go to the database to confirm my changes, I will see that nothing has happened
You're looking in the wrong database. You're looking in the source database, which is not the one your app makes changes to. The source database is in the same folder as all the other source files. Just like the other source files, you only make changes to it through the IDE. When you build your project the output goes under your bin folder. That output includes a copy of the database. It's that database that your app makes changes to.
if I run the program again all changes will have reverted to the original state
When you debug the app again you are building again, so a new copy is created under the bin folder that overwrites the one you lasy made changes to.

Follow the first link in my signature for the official explanation. Ignore the warning about "Copy if Newer".
 
You know i realized yesterday that if I changed my path it all worked right, and this still didn't occur to me. Thanks, that certainly makes things a lot more clear!
 

Latest posts

Back
Top