Database edit then save problem

Im trying to make a database and for the most part it works. The form1 has add new button (which goes into my form2 window that adds all of the information there, then I hit save, when I exit it and comes back to the form1, with everything saved. There is a listbox that shows all the names, then I click on anyone of the names and try to edit it and it works, then I hit the save button, it comes up with the error under

Me.TableAdapterManager.UpdateAll(Me.Assignment10DataSet)

am I doing something wrong or do I need to make an edit button, if so how do I code this

This is my form1 code

Public Class Form1

    Private Sub ContactBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ContactBindingNavigatorSaveItem.Click
       
        First_nameTextBox.Enabled = True
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Assignment10DataSet.contact' table. You can move, or remove it, as needed.
        Me.ContactTableAdapter.Fill(Me.Assignment10DataSet.contact)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.Show()

    End Sub

   

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Validate()
        Me.ContactBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Assignment10DataSet)
        MsgBox("Saved")

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Validate()
        Me.ContactTableAdapter.Delete(Me.First_nameTextBox.Text, Me.Last_nameTextBox.Text)

        Me.ContactTableAdapter.Fill(Me.Assignment10DataSet.contact)


        MsgBox("Deleted")
    End Sub
End Class

and this the form2 code

Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.Close()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Form1.ContactTableAdapter.Insert(Me.TextBox1.Text, Me.TextBox2.Text,
                                         Me.TextBox3.Text, Me.TextBox4.Text,
                                         Me.TextBox5.Text, Me.TextBox6.Text,
                                         Me.TextBox7.Text, Me.TextBox8.Text,
                                         Me.TextBox9.Text)

        Form1.ContactTableAdapter.Fill(Form1.Assignment10DataSet.contact)

        MsgBox("completed")

        For Each item As Control In Me.Controls
            If TypeOf item Is TextBox Then
                item.Text = String.Empty
            End If
        Next




    End Sub
End Class

could someone help me

hi can i assume this is the code you are using to update the database

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Me.Validate()
        Me.ContactBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.Assignment10DataSet)
        MsgBox("Saved")
 
    End Sub

if so then this is actually the code that updates your database but if you have made changes to to data that you have pulled in from the database you need to write an sql update to make these changes.

the way it works is when you work with a database VB creates an instance of the database and thats what you can manipulate the code above simply saves the changes to the instance out to the real database but yours save on form1 doesn't apply any changes to the instance

dont panic though you just use query builder make an update sql something like this

UPDATE contact
SET fisrt_Name=? and Last_Name=? (and so on with all your fields that need updated)
Where First_Name =? (you can change your parameter if you like just to illustrate with WHERE best to use a unique identifier like primary key)


Hope this helps

This question has already been answered. Start a new discussion instead.