Hello, help me please. I have a db sample ( http://i.imgur.com/JRZ2ojP.png )
I have 1 combobox and 1 textbox

If the combobox select "Notebook" then on the textbox it must be display the corresponding itemStock (3)

Please :(

By the this my simple code for my combobox

Try
            Query = "SELECT * FROM tbl_items"

            MySqlCommand = New MySqlCommand(Query, CNN)
            MySqlDataReader = MySqlCommand.ExecuteReader

            combItems.Items.Clear()

            Do While MySqlDataReader.Read
                       combItems.Items.Add(MySqlDataReader(1))
            Loop


            End If

        Catch ex As Exception
            MessageBox.Show(ex.ToString, "Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            MySqlDataReader.Close()
        End Try

You will have to program on the ComboBox's SelectedIndexChanged event and fire the code then.

You will have to retreive the value from the database and post it to the textbox.

For example:

Private Sub combItems_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles combItems.SelectedIndexChanged
    Try
        Query = "SELECT itemStock FROM tbl_items WHERE itemName='{0}'"
        String.Format(Query,TryCast(sender,ComboBox).SelectedItem.Text)
        MySqlCommand = New MySqlCommand(Query, CNN)
        MySqlDataReader = MySqlCommand.ExecuteReader

        Do While MySqlDataReader.Read
            TextBox1.Text = MySqlDataReader(0)
        Loop
    Catch ex As Exception
        MsgBox(ex.ToString)
    End Try
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.