title: Update Selected Row DataGridView
body: <p>I building a small app writen in Visual Basic.NET, but i need your help. I have DataGridView to display my database and i want make "update" button to update from DataGridView to database. But before update, i want to selected row in DataGridView like this:</p>
  
  <p><img src="https://i.stack.imgur.com/PzCKR.gif" alt="Selected row"></p>
  
  <p>and show to textbox. So, i made a change from textbox for update my database. How to do it?</p>
  
  <p>Here is my code for update:</p>
  
  <pre><code>Private Sub btnPesEdit_Click(sender As Object, e As EventArgs) Handles btnPesEdit.Click
          Koneksi()
  
          Dim konfEdit As DialogResult = MsgBox("Apakah data yang di-update sudah benar?",
                                               MessageBoxButtons.YesNo, "Konfirmasi")
  
          Try
              str = "UPDATE data_pesanan SET (@namakons, @almtkons, @tglpesan, @jenispaket, @jmlpesan, @totaluang) WHERE (@kodekons)"
  
  
              comm = New MySqlCommand(str, conn)
  
              comm.Parameters.AddWithValue("@kodeKons", txtPesKodeKonsu.Text)
              comm.Parameters.AddWithValue("@namakons", txtPesNamaKonsu.Text)
              comm.Parameters.AddWithValue("@almtkons", txtPesAlmtKonsu.Text)
              dtPesTglPesan.CustomFormat = "dd-MM-yyyy"
              comm.Parameters.AddWithValue("@tglpesan", dtPesTglPesan.Value)
              comm.Parameters.AddWithValue("@jenispaket", lblPesJenisPkt.Text)
              comm.Parameters.AddWithValue("@jmlpesan", Convert.ToInt32(txtPesJmlPesan.Text))
              comm.Parameters.AddWithValue("@totaluang", Convert.ToInt32(lblPesTotal.Text))
  
              comm.ExecuteNonQuery()
              conn.Close()
          Catch ex As Exception
              MsgBox(ex.InnerException.Message)
              'MsgBox(ex.Message)
          End Try
      End Sub
  </code></pre>
  
  <p>And here is my code to display from database into DataGridView:</p>
  
  <pre><code>Private Sub tablePesanan()
          Koneksi()
  
          comm = New MySqlCommand("select * from data_pesanan", conn)
          dataAdap = New MySqlDataAdapter(comm)
          Dim dataTbl As New DataTable
          dataAdap.Fill(dataTbl)
          tblPesList.DataSource = dataTbl
          tblPesList.ReadOnly = True
      End Sub
  </code></pre>
  
  <p>Note:
  I'm sorry if my English is bad. I hope you understand what I'm saying.</p>