0

I have no idea how to use parameterized and would like someone to point me into the right direction.

Here's what I'm currently using.

Public Class main
Dim dbCon As New MySqlConnection("Server=localhost;Database=payid;Uid=root")
Dim strQuery As String = ""
Dim SQLCmd As MySqlCommand
Dim DR As MySqlDataReader
Private Sub Use()
    Try
        strQuery = "UPDATE payid " & _
            "SET used='" & amen.Text & "' " & _
             "WHERE payid='" & TextBox1.Text & "'"

        SQLCmd = New MySqlCommand(strQuery, dbCon)
        dbCon.Open()
        SQLCmd.ExecuteNonQuery()
        dbCon.Close()

    Catch ex As Exception
        MsgBox(ex.Message)
    End Try
End Sub

If someone could change that for me I'd be able to do the rest of my code.

1 Answers1

0
strQuery = "UPDATE payid SET used=@used WHERE payid=@payid "
SQLCmd = New MySqlCommand(strQuery, dbCon)
SQLCmd.Parameters.AddWithValue("@used", amen.Text)
SQLCmd.Parameters.AddWithValue("@payid", TextBox1.Text )
apomene
  • 14,282
  • 9
  • 46
  • 72