so i have a working ish program now, when i add the record it saves and returns the save message box as it should and is viewable in the database where it saves to, but it is not viewable in the text boxes when looking back at the form until i close program and re open it, then i can see the record stored in the database, it just wont update the form, but it should, here is the code whats going on here (probably easy fix just wont make sense in my head)

Private Sub btncommit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btncommit.Click

        Dim cb As New OleDb.OleDbCommandBuilder(da)
        Dim dsnewrow As DataRow

        da.Fill(ds, "Appointment")

        dsnewrow = ds.Tables("tblCustomers").NewRow()

        dsnewrow.Item("CustomerID") = txtcustomerid.Text
        dsNewRow.Item("GroupName") = txtgroupname.Text
        dsNewRow.Item("Forename") = txtforename.Text
        dsNewRow.Item("Surname") = txtsurname.Text
        dsNewRow.Item("DateOfBirth") = txtdob.Text
        dsNewRow.Item("Address") = txtaddress.Text
        dsNewRow.Item("Town") = txttown.Text
        dsNewRow.Item("County") = txtcounty.Text
        dsNewRow.Item("Postcode") = txtpostcode.Text
        dsNewRow.Item("Telephone") = txttelephone.Text


        ds.Tables("tblCustomers").Rows.Add(dsNewRow)
        da.Fill(ds, "tblCustomers")
        da.Update(ds, "tblCustomers")

        MsgBox("New Record added to the Database")

        btncommit.Enabled = False
        btnsavecustomer.Enabled = True
        btneditcustomer.Enabled = True
        btndeletecustomer.Enabled = True

        ' End If


    End Sub

Recommended Answers

All 2 Replies

I believe your Dataset Update Command should come before your DataAdapter Fill Command. You would be just refilling anything in the Database Table to the DataSet wiping out your record during runtime. That's why when you restart it shows up.

ds.Tables("tblCustomers").Rows.Add(dsNewRow)        
da.Update(ds, "tblCustomers")
da.Fill(ds, "tblCustomers")

I also do not see where you are using a BindingSource for the TextBoxes then ResetBindings(False). It would make it easier but it isn't necessary.

yeah thanks, i looked back at it and realized in the end, thanks a lot though it will help careless idiots like me in the future :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.