title: VB.Net Update Command Not Working
body: <p>I am new to VB.Net and am having a great deal of trouble with a Windows Form Application.  </p>
  
  <p>I have a button on my form that I am trying to set to update my local SQL Server database.  Here is the code that I currently have behind my Save button.  I've adjusted the code behind my Save button, and it now looks like this:</p>
  
  <pre><code>    Public Property InsertCommand As SqlCommand
      Public Property cn As SqlConnection     
      Private Sub b_Save_Click(sender As Object, e As EventArgs) Handles b_Save.Click
           Try
  
          Dim row As CV_Calls_DBDataSet.CV_Main_tblRow = DS_CV_Calls_DB.CV_Main_tbl.NewCV_Main_tblRow
  
          row.Call_Base_num = Me.CallNumber_mtx.Text
          row.Cash_Vendor_Code = Me.cbo_Vendor.Text
          row.Error_Code = Me.cbo_Error.Text
          row.Error_Location_Code = Me.cbo_Location.Text
          row.RowID = DS_CV_Calls_DB.CV_Main_tbl.Count + 1
  
          DS_CV_Calls_DB.CV_Main_tbl.AddCV_Main_tblRow(row)
          cn = New SqlConnection("Data Source=(LocalDB)\v11.0;Database=|DataDirectory|\CV_Calls_DB.mdf;Integrated Security=TRUE;")
          CreateCallAdapter(cn)
          'For Each row In DS_CV_Calls_DB.CV_Main_tbl.Rows
          '    Debug.WriteLine(row.RowState)
          '    Debug.WriteLine(row.Call_Base_num)
          '    Debug.WriteLine(row.Cash_Vendor_Code)
          '    Debug.WriteLine(row.Error_Location_Code)
          '    Debug.WriteLine(row.Error_Code)
          '    Debug.WriteLine(row.RowID)
          'Next
  
  
          TA_CV_Main.Update(DS_CV_Calls_DB.CV_Main_tbl)
          CreateCallAdapter(cn)
          MessageBox.Show(DS_CV_Calls_DB.HasChanges())
          MessageBox.Show("Saved!")
          Me.Close()
      Catch ex As Exception
          MessageBox.Show(ex.ToString)
      End Try
  End Sub
  
      Public Function CreateCallAdapter(ByVal connection As SqlConnection) As SqlDataAdapter
      Dim adapter As SqlDataAdapter = New SqlDataAdapter
      Dim command As SqlCommand = New SqlCommand("Select * FROM CV_Main_tbl", connection)
      'Create InsertCommand
      command = New SqlCommand("INSERT INTO CV_Main_tbl (Call_Base_num, Cash_Vendor_Code, Error_Location_Code, Error_Code) VALUES (@Call_Base_num, @Cash_Vendor_Code, @Error_Location_Code, @Error_Code)", connection)
      'Add the parameters for the InsertCommand
  
      command.Parameters.Add("@Call_Base_num", SqlDbType.Int, Me.CallNumber_mtx.Text)
      command.Parameters.Add("@Cash_Vendor_Code", SqlDbType.SmallInt, Me.cbo_Vendor.Text)
      command.Parameters.Add("@Error_Location_Code", SqlDbType.SmallInt, Me.cbo_Location.Text)
      command.Parameters.Add("@Error_Code", SqlDbType.SmallInt, Me.cbo_Error.Text)
      command.Parameters.Add("@RowID", SqlDbType.Int, DS_CV_Calls_DB.CV_Main_tbl.Count + 1)
      adapter.InsertCommand = command
      Return adapter
  End Function
  </code></pre>
  
  <p>When I run this code, I still get a message saying that the data was saved.  However, when I check the actual table via the Server Explorer, nothing has been added.  Do you have any suggestions as to what I am doing wrong?</p>