Hello there,
How to add items in combo box from mysql database?

'mySQL statement
'tryCatch method

ComboBox1._______ = myReader.GetValue(myReader.GetOrdinal("Uname"))

I'm trying use this:

ComboBox1.items = myReader.GetValue(myReader.GetOrdinal("Uname"))

but an error occured.

Recommended Answers

It helps if you post the error message, but to add items to a combobox the syntax is

ComboBox1.Items.Add(string value)

in your case

ComboBox1.Items.Add(myReader("Uname"))
Jump to Post

All 3 Replies

It helps if you post the error message, but to add items to a combobox the syntax is

ComboBox1.Items.Add(string value)

in your case

ComboBox1.Items.Add(myReader("Uname"))

I did not use yet the Items.Add systax. Instead, I use this:

ComboBox1.Text = myReader.GetValue(myReader.GetOrdinal("Uname"))

just for comparizon.

ComboBox1.Text is the text from the currently selected item.

Be a part of the DaniWeb community

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