Help with vb.net code save button to a sql database using datagridview

Hello. I am fairly new to programming and I am learning vb.net. I am currently using visual studio 2017 community. I created a form the contains entry fields along with a dataviewgrid that stores the information based on what was entered in the text boxes. The data is being stored on a sql database (2008). My form has two buttons. An add new button and save button. Basically I enter info in my text boxes then hit the add button, This populates my data grid. The issue I am having is with my save button. When I press the save button I received the following error:

System.InvalidOperationException: 'Update requires a valid updatecommand when passed datarow collection with modified rows. I don't know how to correct this? Below is my simple code if it helps.

Public Class Form1
    Private Sub CamTagIssueBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles CamTagIssueBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.CamTagIssueBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ControlledItemsDataSet)

    End Sub

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

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        CamTagIssueBindingSource.AddNew()
        CameraTextBox.Focus()



    End Sub

    Private Sub Save_Click(sender As Object, e As EventArgs) Handles Save.Click
        Me.Validate()
        Me.CamTagIssueBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.ControlledItemsDataSet)

    End Sub
End Class
DJ PAsked:
Who is Participating?
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
If you're using a TableAdapter or DataAdapter, then you have to set the various "commands" for that adapter. There are several - INSERT, UPDATE, DELETE - and they are, essentially, SQL Statements that perform those tasks.

Here's a link that might help: https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/updating-data-sources-with-dataadapters

That contains links which explains how to create those commands.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.