populate combo box from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baasu
    New Member
    • Aug 2007
    • 8

    populate combo box from database

    i want to populate a combo box with items in the table of my access database. i ve seen some code on the internet but wasnt able to understand dem much.pls help!
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    What version of vb are you using?

    Rey Sean

    Comment

    • baasu
      New Member
      • Aug 2007
      • 8

      #3
      hi
      i am using vb6
      thnx

      Comment

      • lotus18
        Contributor
        • Nov 2007
        • 865

        #4
        [CODE=vb]
        Dim con As New ADODB.Connectio n
        Dim rs As New ADODB.Recordset

        Set dbConnection = New ADODB.Connectio n
        dbConnection.Op en "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & <Database Path>;Persist Security Info=False;Jet OLEDB:Database Password=<YourP assword>" 'If Any

        rs.Open "Select * From <TableName>", con, 1, 1

        While Not rs.EOF
        Combo1.AddItem rs!<FieldName>
        rs.MoveNext
        Wend

        rs.Close
        Set rs=Nothing

        con.Close
        Set con=Nothing

        [/CODE]

        Rey Sean

        Comment

        • dauz
          New Member
          • Jul 2008
          • 1

          #5
          Hi did you know how to query Geom from Oracle Spatial using VB6...

          thanks in advance!!

          Originally posted by lotus18
          [CODE=vb]
          Dim con As New ADODB.Connectio n
          Dim rs As New ADODB.Recordset

          Set dbConnection = New ADODB.Connectio n
          dbConnection.Op en "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=" & <Database Path>;Persist Security Info=False;Jet OLEDB:Database Password=<YourP assword>" 'If Any

          rs.Open "Select * From <TableName>", con, 1, 1

          While Not rs.EOF
          Combo1.AddItem rs!<FieldName>
          rs.MoveNext
          Wend

          rs.Close
          Set rs=Nothing

          con.Close
          Set con=Nothing

          [/CODE]

          Rey Sean

          Comment

          Working...