Error when saving a record to database

PIOTR DROZD 116 Reputation points
2021-04-02T12:10:01.347+00:00

I'm trying to create a save button in the form to save changes to a record made by the user.
When I run the code I get the error message unable to save to the database.
In the form the records are displayed in a data grid and then each record is displayed in text boxes.
After trying to save I get a red dot in the datagrid which says incorrect syntax near ','.
Here is the code that I'm using

 Private Sub BtnSave_Click(sender As Object, e As EventArgs) Handles BtnSave.Click

    Try
        Dim result As New DialogResult()
        result = MessageBox.Show("Do you really want to save the record?", "Save Data", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If result = DialogResult.Yes Then

            Me.Validate()
            Me.CustomerRequestsBindingSource.EndEdit()
            Me.CustomerRequestsTableAdapter.Update(Me.AzureDataSet.CustomerRequests)

            MessageBox.Show("Record has been saved successfully", "Save Data", MessageBoxButtons.OK,
               MessageBoxIcon.Information)

            Me.CustomerRequestsTableAdapter.Fill(Me.AzureDataSet.CustomerRequests)

        Else
            Return
        End If

    Catch ex As Exception
        MessageBox.Show("Unable to save to database", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Stop)
    End Try

End Sub
Azure SQL Database
Developer technologies VB
{count} votes

Accepted answer
  1. PIOTR DROZD 116 Reputation points
    2021-04-02T12:56:08.857+00:00

    Thank you. I got to the bottom of this, turns out the table adapter was not configured for UPDATE. All working fine now :)


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.