VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Populate a combo box from a database backend without using an ADODC Control.

by Sehri Yazdani (1 Submission)
Category: Databases/Data Access/DAO/ADO
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 27th April 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Populate a combo box from a database backend without using an ADODC Control.

API Declarations


Dim Con as ADODB.Connection
Dim ssql as String
Const strCon =_ "DSN=Contacts;Description=Contacts;SERVER=ServerName;UID=sa;Password=;"

Rate Populate a combo box from a database backend without using an ADODC Control.




    Set Con = New ADODB.Connection
    Set rs = New ADODB.Recordset
    Con.Open strCon
    
    'sql statement to select items on the drop down list
    ssql = "Select LastName From Contacts"
    rs.Open ssql, Con
    
    Do Until rs.EOF
        combo1.AddItem rs("LastName")   'Adds lastnames to dropdown list
        rs.MoveNext
    Loop
    
    'Close connection and the recordset
    rs.Close
    Set rs = Nothing
    Con.Close
    Set Con = Nothing
End Sub

Download this snippet    Add to My Saved Code

Populate a combo box from a database backend without using an ADODC Control. Comments

No comments have been posted about Populate a combo box from a database backend without using an ADODC Control.. Why not be the first to post a comment about Populate a combo box from a database backend without using an ADODC Control..

Post your comment

Subject:
Message:
0/1000 characters