I have a drop down combo that I need to populate with the items from my database. However, I also need to remove any duplicate entries when pulling over from the database, so I can't just use the datasource property of the combobox. Any suggestions as to how I can populate the combobox items with the items in my database?Vb 2008 How can I convert a database column into a list so I can fill a combobox?
You can use basic idea about it and can use it in your project.
I made this in vb6.0. I created a function called as fillcombo(). like this-
Private Sub FillCombo()
Dim rsFill As New ADODB.Recordset
Dim strFill As String
strFill = ';';
strFill = '; Select distinct sub_name from Subscription';
If rsFill.State = 1 Then rsFill.Close
cmbname.Clear
rsFill.Open strFill, conn, adOpenKeyset, adLockOptimistic
While rsFill.EOF %26lt;%26gt; True
cmbname.AddItem rsFill!sub_name %26amp; ';';
rsFill.MoveNext
Wend
End Sub
You can call this function on page load.
No comments:
Post a Comment