Update mysql data or record using VB.net with datagridview
<p>Hi guys I need help in updating the data on my datagridview. The Scenario is when I click the Search it will query the appropriate data and display that I want to the datagridview. Then I want to update if their any changes or deleted data from datagridview then also update to my mysql table for new data or record whenever I click the Update Button and it will prompts a messagebox if their is a successfully changes to my data and prompts if their is no changes to my data. I really need help the codes for update button.
Here is my code to the search button to the datagridview:</p>

<pre><code>Imports MySql.Data.MySqlClient
Public Class Form1
    Dim conn As New MySqlConnection
    Dim result As Integer
    Dim cmd As New MySqlCommand
    Dim da As New MySqlDataAdapter
    Dim ds As New DataSet
    Dim dr As MySqlDataReader
    Dim sql As String
    Dim dt As New DataTable

 Private Sub cmdSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSearch.Click
        con.ConnectionString = ("server=127.0.0.1;user id=root;password=12345;database=dbsis3bkenth;")

Try
            conn.Open()

        sql = "SELECT LName,FName,MI FROM tblsisterbrother where IDNoBrodSis = '" &amp; cbIDNo.Text &amp; "'"
        cmd = New MySqlCommand(sql, conn)
        dr = cmd.ExecuteReader
        dr.Read()

        If dr.HasRows = True Then
            MessageBox.Show("Record Found.!")
        Else
            MessageBox.Show("Record Unfound.!")
        End If
        dr.Close()
    Catch ex As MySqlException
        MessageBox.Show("Error in searching to database:error is:" &amp; ex.Message)
        Exit Sub
    End Try
    dr.Close()
    RemoveHandler DataGridView1.CellValidating, AddressOf DataGridView1_CellValidating
    Dim DataAdapter1 As MySqlDataAdapter = New MySqlDataAdapter
    DataAdapter1.SelectCommand = cmd
    DataAdapter1.Fill(ds, "tblsisterbrother")
    DataGridView1.DataSource = ds
    DataGridView1.DataMember = "tblsisterbrother"
    conn.Dispose()
    conn.Close()

End Sub
</code></pre>

<p>Then I want a code for the update, it will be place here:</p>

<pre><code> Private Sub cmdUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdUpdate.Click
</code></pre>

<p>I want this kind of messagebox appears if the rows affected, this code does not run to what I want, just for reference on how to update. Please help me :)</p>

<pre><code>If DataGridView1.DataSource.GetChanges() Is Nothing Then
            MessageBox.Show("The table contains no changes to save.")
        Else
            Dim rowsAffected As Integer = da.Update(dt)
            If rowsAffected = 0 Then
                MessageBox.Show("No rows were affected by the save operation.")
            Else
                MessageBox.Show(rowsAffected &amp; " rows were affected by the save operation.")
            End If
        End If
        End Sub
</code></pre>