title: What is the code for VB.Net to delete and update data in MySQL ? (Use parameterized Query)
body: <p>What is the code for VB.Net to delete and update data in MySQL ? (Use parameterized Query)</p>
  
  <p>This is my code for Update :</p>
  
  <pre><code>Dim Query As String
  
      Dim con As MySqlConnection = New MySqlConnection("Data Source=localhost;Database=test;User ID=root;Password=;")
      con.Open()
  
      Query = "UPDATE userreg SET UserName ='" + txtUserName.Text + "',"
      Query = Query + "Age = " + txtAge.Text
      Query = Query + " WHERE idUserReg = " + txtUserRegId.Text
  
      Dim cmd As MySqlCommand = New MySqlCommand(Query, con)
      MsgBox(Query)
      Dim i As Integer = cmd.ExecuteNonQuery()
      If (i &gt; 0) Then
          lblMsg.Text = "Record is Successfully Updated"
      Else
          lblMsg.Text = "Record is not Updated"
      End If
      con.Close()
  </code></pre>
  
  <p>And this is for Delete Code :</p>
  
  <pre><code> Dim Query As String
  
      Dim con As MySqlConnection = New MySqlConnection("Data Source=localhost;Database=test;User ID=root;Password=;")
      con.Open()
      Query = "Delete FROM userreg WHERE idUserReg  =" + txtUserRegId.Text
  
      Dim cmd As MySqlCommand = New MySqlCommand(Query, con)
      MsgBox(Query)
      Dim i As Integer = cmd.ExecuteNonQuery()
      If (i &gt; 0) Then
          lblMsg.Text = "Record is Successfully Deleted"
      Else
          lblMsg.Text = "Record is not Deleted"
      End If
      con.Close()
  </code></pre>
  
  <p>But when I want update and delete data, there is no change.</p>