title: How to update a datagridview using vb.net
body: <p>I am using the below mention code to update and delete data from datagridview. but i am unable to solve this issue. Delete is working but not update.</p>
  
  <p>Public Sub CustomerUpdateBatch(ByVal dt As DataTable)</p>
  
  <pre><code>    Dim connection As SqlConnection = New SqlConnection(Invoice.GetConnect())
      connection.Open()
      Try
  
          Dim command As SqlCommand = New SqlCommand("Update_Customer", connection)
          command.CommandType = CommandType.StoredProcedure
          command.Parameters.Add("@C_ID", SqlDbType.Int, 16, "C_ID")
          command.Parameters.Add("@C_Name", SqlDbType.VarChar, 50, "C_Name")
          command.Parameters.Add("@C_Address", SqlDbType.VarChar, 50, "C_Address")
          command.Parameters.Add("@C_Tel", SqlDbType.VarChar, 50, "C_Tel")
          command.Parameters.Add("@C_Fax", SqlDbType.VarChar, 50, "C_Fax")
          command.Parameters.Add("@C_Mobile", SqlDbType.VarChar, 50, "C_Mobile")
          command.Parameters.Add("@C_Email", SqlDbType.VarChar, 50, "C_Email")
          command.Parameters.Add("@C_Tin", SqlDbType.VarChar, 50, "C_Tin")
          command.Parameters.Add("@C_Remarks", SqlDbType.VarChar, 50, "C_Remarks")
          command.CommandType = CommandType.StoredProcedure
  
          Dim delcommand As SqlCommand = New SqlCommand("Delete_Customer", connection)
          delcommand.CommandType = CommandType.StoredProcedure
          command.Parameters.Add("@C_ID", SqlDbType.Int, 16, "C_ID")
  
          Dim adapter As SqlDataAdapter = New SqlDataAdapter()
          adapter.UpdateCommand = command
          adapter.DeleteCommand = delcommand
          adapter.DeleteCommand.UpdatedRowSource = UpdateRowSource.None
          adapter.Update(dt)
  
      Catch ex As Exception
          Console.WriteLine(ex.Message)
          Throw
      Finally
          connection.Close()
      End Try
  End Sub
  </code></pre>