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

Recommended Answers

All 2 Replies

  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

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

Thanks

Don

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.