Search error in mysql with visual basic .net

0

Good day, Send me this error

  

executereader the connection property has not been initialized

the error sends it here%% of%

Private Sub btnAgregar_Click(sender As Object, e As EventArgs) Handles btnBuscar.Click
        If (validarCampos() = False) Then
            MsgBox("Campos vacios", MsgBoxStyle.Information, "Validacion")
        Else


            SQL = "SELECT * FROM usuario WHERE UsuCod='" & txtCodigo.Text & "'"
            rst = BaseDatos.leer_Registro(SQL)

            If rst.Read() Then
                txtNombre.Text = rst(1)
                txtApellido.Text = rst(2)
                cmbRol.SelectedIndex = rst(3)
                txtEmail.Text = rst(6)
            Else
                MsgBox("El usuario a consultar no existe", MsgBoxStyle.Information, "Validacion")

            End If
        End If

    End Sub

this is the function that reads me

Public Shared Function leer_Registro(ByVal sql As String) As OdbcDataReader
        Try
            orden = New OdbcCommand(sql, conexion)
            Return orden.ExecuteReader()
        Catch ex As Exception
            MsgBox(ex.Message)
            MessageBox.Show("Error al leer Registro en la Base de Datos", "Error",
            MessageBoxButtons.OK, MessageBoxIcon.Error)
            Return Nothing
        End Try
    End Function
    
asked by MZ39720 17.10.2018 в 17:01
source

0 answers