How to check if there is a record on vb.net and mysql

1

I need to verify if the record exists in the "Product" field to make an update in the.

 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Dim Conexion As New MySqlConnection("data source=localhost; user=root; password=; database=importaciones;")
    Dim Comando As MySqlCommand
    Dim ConsultaSQL As String
    Dim Reader As MySqlDataReader
    If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Then
        MsgBox("Por favor complete todos los datos")
    Else
        Try
            Conexion.Open()
            ConsultaSQL = "UPDATE productos SET Costo='" & TextBox2.Text & "' , Precio='" & TextBox3.Text & "'  WHERE Producto='" & TextBox1.Text & "' "
            Comando = New MySqlCommand(ConsultaSQL, Conexion)
            Reader = Comando.ExecuteReader()
            Conexion.Close()
        Catch Exep As Exception
            MsgBox(Exep.Message)
        End Try

        MsgBox("Registro actualizazdo correctamente")
        TextBox1.Text = ""
            TextBox2.Text = ""
            TextBox3.Text = ""
        End If
        Form2.actualizar()
End Sub
    
asked by Tutee United 18.12.2017 в 23:34
source

0 answers