By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

populate combo box from database

P: 8
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!
Jun 26 '08 #1
Share this Question
Share on Google+
4 Replies


lotus18
100+
P: 866
What version of vb are you using?

Rey Sean
Jun 26 '08 #2

P: 8
hi
i am using vb6
thnx
Jun 27 '08 #3

lotus18
100+
P: 866
Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim con As New ADODB.Connection
  3. Dim rs As New ADODB.Recordset
  4.  
  5. Set dbConnection = New ADODB.Connection
  6.     dbConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & <Database Path>;Persist Security Info=False;Jet OLEDB:Database Password=<YourPassword>" 'If Any
  7.  
  8.     rs.Open "Select * From <TableName>", con, 1, 1
  9.  
  10.     While Not rs.EOF
  11.         Combo1.AddItem rs!<FieldName>
  12.         rs.MoveNext
  13.     Wend
  14.  
  15.      rs.Close
  16.      Set rs=Nothing
  17.  
  18.     con.Close
  19.     Set con=Nothing
  20.  
  21.  
Rey Sean
Jun 27 '08 #4

P: 1
Hi did you know how to query Geom from Oracle Spatial using VB6...

thanks in advance!!

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim con As New ADODB.Connection
  3. Dim rs As New ADODB.Recordset
  4.  
  5. Set dbConnection = New ADODB.Connection
  6.     dbConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & <Database Path>;Persist Security Info=False;Jet OLEDB:Database Password=<YourPassword>" 'If Any
  7.  
  8.     rs.Open "Select * From <TableName>", con, 1, 1
  9.  
  10.     While Not rs.EOF
  11.         Combo1.AddItem rs!<FieldName>
  12.         rs.MoveNext
  13.     Wend
  14.  
  15.      rs.Close
  16.      Set rs=Nothing
  17.  
  18.     con.Close
  19.     Set con=Nothing
  20.  
  21.  
Rey Sean
Jul 10 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.