473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

populate combo box from database

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
4 2370
lotus18
866 512MB
What version of vb are you using?

Rey Sean
Jun 26 '08 #2
baasu
8
hi
i am using vb6
thnx
Jun 27 '08 #3
lotus18
866 512MB
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
dauz
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

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

Similar topics

0
by: BK | last post by:
Hi, I have a problem. I need to auto populate fields based on a value entered in combo box. Initially, I put all the required fields in the combo box, and hide it (set to 0",0",0", ...), then...
4
by: Mike L | last post by:
I'm open for any suggestions on how to better program this. I want the user to select a license from a combo box, cboPrivilege and then the user will click the add button, then a record will be...
2
by: Dave McKie | last post by:
Hi all I am trying to Populate a combo box from a selection in an adjacent Listview. The Listview lists as a string the field names of 4 different fields in tblFile. So far I can populate the...
16
by: agrawal.solutions | last post by:
Hello Friends I am asking a very silly question but i dont find any solution fo this.. I am selectiong a recordset and want to populate a combobox where id would be inviseble and the content...
5
by: jdwyer05 | last post by:
Hello, I am trying to populate a combo box with only unique values. Currently I am using an access database and VB6 Enterprise. The program populates the combo box fine however, there are several...
29
by: gedwards | last post by:
First off, I am a complete newbie to Access. I've used it maybe a half dozen times, all my database knowledge is with Oracle. I'm building a database/form in Access 2003. I'm trying to get it so...
7
by: nareshpulipati | last post by:
Hi all, I am new to VB .net. Iam trying to populate the database item into combo box. Database Type:SQL(ODBC) My code retuns no value in combo box Public Class Form1 Private Sub...
4
by: whamo | last post by:
I have the need to populate a field based on the selection in a combo box. Starting out simple. (2) tables tbl_OSE_Info and tbl_Input; tbl_OSE_Info has three fields: Key, OSE_Name and OSE_Wt...
1
by: OblongPlatypus | last post by:
Hi, I am fairly new to VB and I am using Visual Studio 2005. I am currently trying to make a simple programme to search a database using 2 different combo boxes to define the search parameters. The...
5
by: giandeo | last post by:
Hello Experts. Could you find a solution for this problem please! I have the following tables in Access Database Table Name: origin Fields Names: country, countrycode Table Name: make...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.