0

Hi group!

I have what I hope is a unique question:

In need to populate a combo Box with the information stored in 6 different columns on one row of a data table. I know how to do this if it just one column and one row.

To be specific, I have one row of data that contains 'Unit of Measure' information within 6 different column names. They are UMName, UMName2, UMName3, UMName4, UMName5 and UMName6. This data is attached to one specific part number. Would someone know how I can get the one piece of info from each one of these column into the combo box? Obviously a loop won't do it since all the info is within one row. So you know, I've been using the syntax as follows:

            cmbxUnitMeasure.Items.Add(umName) 'also need umName2, umName3......
            cmbxUnitMeasure.Text = "Select from..." 

Thoughts... Ideas?

In advance, thanks for your help.

Don

2
Contributors
2
Replies
25
Views
3 Years
Discussion Span
Last Post by doncwilson_1
1
  1. you mean get data from database?
  2. get data from one row with 6 column?
    if yes, i would do with reader.

example with mysql database :

i have 1 table in my database, on that table i have 3 columns, so ..

Try
            Using conn As New MySqlConnection("MY CONNECTION STRING")
                conn.Open()
                Dim command As New MySqlCommand("select * from MY_TABLE", conn)
                Dim reader As MySqlDataReader = command.ExecuteReader
                If reader.Read() Then
                    With ComboBox1.Items
                       .Add(reader(0).ToString)
                       .Add(reader(1).ToString)
                       .Add(reader(2).ToString)
                    End With
                End If
                reader.Close()
                command.Dispose()
                conn.Close()
            End Using
Catch ex As Exception
            MsgBox(ex.Message)
End Try

Edited by artemix22

0

I'll give this one a whirl! I didn't realize you could do this! I learn something everyday!!

Thanks

Don

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.