how to store all items of database to combo box.
i.e. store complete column in combo box?
Iamateur
0
Junior Poster in Training
Recommended Answers
Jump to PostLike:
Using conn As New SqlConnection("connString") Using cmd As SqlCommand = New SqlComand("SELECT ColumnName FROM TableName", conn) Using reader As SqlDataReader = cmd.ExecuteReader() While reader.Read() comboBox1.Items.Add(reader(0).ToString()) End While End Using End Using End Using
Jump to PostHi,
A couple of ways, try this for starters:
dim DR as SQLDataReader dim cmd as SQLCommand cmd = New SqlCommand("SELECT Column FROM table", DBconnection) DBconnection.Open() DR = cmd.ExecuteReader() If DR.HasRows Then Do While DR.Read() MyComboBox.Items.Add(DR.GetString(0)) Loop end if DR.Close()
All 7 Replies
Mitja Bonca
557
Nearly a Posting Maven
G_Waddell
131
Posting Whiz in Training
Iamateur
0
Junior Poster in Training
Iamateur
0
Junior Poster in Training
Iamateur
0
Junior Poster in Training
Iamateur
0
Junior Poster in Training
Mitja Bonca
557
Nearly a Posting Maven
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.