Codigo en el LOAD:
Código vb:
Ver originalPrivate Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataTable
Dim conexion As New MySqlConnection("Server=localhost; Database=controlsmi; user=root; password=Smi2012") 'cadena conexion
Dim SelectedValue As String = "SELECT ID_producto, nombre FROM producto" 'consulta a la tabla
Dim comando As New MySqlCommand(SelectedValue, conexion)
Dim adap As New MySqlDataAdapter(comando)
conexion.Open()
adap.Fill(dt)
conexion.Close()
cboproducto.DataSource = dt
cboproducto.DisplayMember = "nombre"
cboproducto.ValueMember = "ID_producto"
cboproducto.SelectedIndex = -1
Codigo en el EVENTO:
Código vb:
Ver originalDim dt As New DataTable
Dim conexion As New MySqlConnection("Server=localhost; Database=controlsmi; user=root; password=Smi2012") 'cadena conexion
Dim SelectedValue As String = "SELECT serial FROM producto where Id_producto=" + cboproducto.SelectedValue.ToString 'consulta a la tabla"
Dim comando As New MySqlCommand(SelectedValue, conexion)
Dim adap As New MySqlDataAdapter(comando)
conexion.Open()
adap.Fill(dt)
conexion.Close()
cboserial.DataSource = dt
cboserial.DisplayMember = "serial"
cboserial.ValueMember = "serial"