473,383 Members | 1,803 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,383 software developers and data experts.

Populating a combobox from a table

Hi All,

Could somebody provide me step by step instructions of how to populate a
combobox with values from a table (any table from northwind.mdb will do).
What I have done is:
- I added on the form combobox
- I added an oledbConnection which I set to point to the Northwind.mdb
database
- I added an oledbDataAdapter
- I generated a dataSet

Then I setup the data properties of ComboBox (DataSource =
dataSource1.MyTable, DisplayMember = MyField, ValueMember = MyIdField)

After I build the program, when I drop down the combobox, there are no items
in it. What am I missing?
I tried to run the sample program ComboBoxBinding provided by Microsoft in
"SDK\v1.1\QuickStart\winforms\samples\" but when I try to run it, it raises
an error.

Regards,
Nicolae

Nov 16 '05 #1
2 1796
Nicolae,

I cannot see the names you use, so probably (accoording partially to your
code)

\\\
OleDb.OleDbDataAdapter1.Fill(DataSource1)
combobox1.DataSource = DataSource1.MyTable;
combobox1.DisplayMember = "MyDisplayMember";
combobox1.ValueMember = "MyFieldId";
///

I hope this helps?

Cor
Nov 16 '05 #2
Hi Cor,

Thank you very much for your tips. It solved my problem. I figured out what
was wrong. On the same form I had a stringgrid and for that one I used the
command:

oleDbDataAdapter1.Fill(dataSet1, "MyField");

While it worked for the stringgrid, it didn't work for the combobox, which
required

oleDbDataAdapter1.Fill(dataSet1);

Regards,
Nicolae
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Big Time | last post by:
Hi, I have a question regarding using drop down lists and how to get them to limit the list of a subsequent field. I have a database which has the names of colleges. Each college has it's own...
8
by: Roy Padgett | last post by:
I have a combo box where users select the customer name and can either go to the customer's info or open a list of the customer's orders. The RowSource for the combo box was a simple pass-through...
5
by: Geoff Portbury | last post by:
I'm a swimming club coach. I have a data base for recording times at various meets. I have a FORM for entering times called SWIM TIMES. When I enter the swimmers name ID, eg FOR01 for Doug Ford I...
0
by: Henry | last post by:
I have a dataset dsMain in which I have two tables The table period has columns like period_id, name, root_org_id.... The table organization has org_id, name, parent_id, hier_path, level,...
2
by: John Ninan | last post by:
I am creating Dynamic Usercontrol in Asp.net application. In this application I have a combobox(aspx Page). Which contains various items. Based on item selected I am dynamically populating...
2
by: Bill Brinkworth | last post by:
in vb.net 2005, i would like to pull up a name from a database (customers) (i can do this already), then after a name is selected from a combox box, to populate the form's text boxes with with data...
4
by: c_shah | last post by:
I am a beginner and learning VB.net There are two wasy to bind a combobox or a listbox First approach is to assign a datasource and displaymember Second approach is to iterate through datarow...
3
by: davenumber40 | last post by:
I’m creating a small database in Access 2003(XP) to track issues during software testing. As far as databases go, it’s going to be a relatively small, short term project (No more than 20,000 records...
6
by: buterfly0707 | last post by:
hi.. i want to fill my combobox from the values which im having in my table in the database. and my combobox name is combobox1 and my table is tblDetails, and this table having two columns code...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.