save button on database won't save

justlearning

Member
Joined
Dec 11, 2008
Messages
16
Programming Experience
Beginner
Hi, I am sorry to bother you but I am desperate for help. I am running vb.net (vb2005). I built two tables using sql and ado.net. Everything works on the entire program except the update/save button. I dragged the tables onto the form so the code was automatically generated. So I am not really sure what I could have done wrong. It was suggested to me that it could be because of my queries but to verify that it was due to the queries I created a new program with one table and no code written by me. I set up the table as a sql data source and dragged it onto the only form in the test program. I ran it and tried to save some changes but it didn't work. This leads me to believe that the automatically generated code is doing something wrong. My code is below for you to see. Please let me know if you can think of any reason why the update/save button wouldn't work.

For verification, when the update/save button is clicked there is literally nothing that changes at all.

Thanks so much for the help....

VB.NET:
Public Class EditMovieForm
    Private Sub TitleBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        'validate for all
        Me.Validate()

        'Title Binding Source and Table Adapter
        Me.TitleBindingSource.EndEdit()
        Me.TitleTableAdapter.Update(Me.SqlmovieprojectdbDataSet)

        ''Starring Binding Source and Table Adapter
        Me.StarringBindingSource.EndEdit()
        Me.StarringTableAdapter.Update(SqlmovieprojectdbDataSet)
    End Sub

    Private Sub editmovieinfo_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Starring' table. You can move, or remove it, as needed.
        Me.StarringTableAdapter.Fillbyabc(Me.SqlmovieprojectdbDataSet.Starring)

        'TODO: This line of code loads data into the 'SqlmovieprojectdbDataSet.Title table. You can move, or remove it, as needed.
        Me.TitleTableAdapter.Fillbyabc(Me.SqlmovieprojectdbDataSet.Title)
    End Sub
    Private Sub embytitlebtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles embytitlebtn.Click
        'call movietitles form
        MovieTitles.Show()
    End Sub
    Private Sub embystarbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles embystarbtn.Click
        'Call moviestars form
        MovieStars.Show()
    End Sub
    Private Sub embygenre_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles embygenre.Click
        'Call genre form
        Genre.Show()
    End Sub
    Private Sub EMexitbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EMexitbtn.Click
        'close editmovieinfo 
        Me.Close()
    End Sub

End Class
 
How EXACTLY are you determining that nothing is changing? What database are you looking in? When? How? You should probably read this as I'm guessing it will show you that the code is working and you're just not looking in the right place or at the right time.
 
Actually I just got it to save by changin the property on my dataset to copy if newer. So that was all it was, a simple setting.

Thank you though for trying to help me.
 
Actually I just got it to save by changin the property on my dataset to copy if newer. So that was all it was, a simple setting.

Thank you though for trying to help me.
Just so you know, it already was saving. By changing that property of your database (NOT DataSet) you are actually preventing the changes being overwritten by a fresh copy of the source database the next time you run the project.
 
Okay, well regardless of what its called it worked. I thank you again.

Danyiell
I don't mean to harp here but I wasn't just giving something a different name. I was trying to help you understand what was happening. Getting something to work without understanding how or why doesn't help you learn and won't prevent you having similar problems in future. If you understand what was happening, before and after the solution, then you can avoid those problems.
 
I actually appreciate that. I said data set instead of database because I thought I clicked on the dataset to change the properties but you were right it was the sql database. I apologize. I am extremely desperate to get this application done and now my foreign keys and primary key isn't working right. I really do thank you for your clarification.

Thank you,
Danyiell
 
Back
Top