Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get data from sql into a combo box in vb6?

Status
Not open for further replies.

Niki_S

Programmer
Jun 4, 2021
232
LK
I want to get data from sql server into my combo box. These are the few steps that I did and I want to know how to insert data to my combo box?
Code:
Private Sub Form_Load()
   
    Call fxSETConnection(ServerType2)
   
    Dim rsreportSw As String
    Dim LnOD As ADODB.Recordset

  
    'rsreportSw = "SELECT cFty FROM dbo.FRI_MASTER_LineLoading group by cFty order by cFty"
    
 
        Set LnOD = New ADODB.Recordset
        LnOD.CursorLocation = adUseClient
        LnOD.Open "SELECT cFty FROM dbo.FRI_MASTER_LineLoading group by cFty order by cFty", cn, adOpenStatic, adLockReadOnly
        
    

End Sub

Thank you
 
One method:

Code:
With LnOD 
    Do While Not .EOF
        Combo1.AddItem ![cFty]
        .MoveNext
    Loop
End With
 
A Star for strongm? Would be nice to show appreciation for his help...

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top