Thank you. I got to the bottom of this, turns out the table adapter was not configured for UPDATE. All working fine now :)
Error when saving a record to database
PIOTR DROZD
116
Reputation points
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
Azure SQL Database
An Azure relational database service.
6,326 questions
Developer technologies VB
2,892 questions