-
Populating a ComboBox from a Dbase
Hello,
I am VERY new at this so this might seem like a simple problem to most,
but what I'm trying to do is populate a combo box from a access database
automaticaly when the form is loaded. It shouldn't be more than 3 - 4 lines
of code but I can't find it anywhere and need it for a school project. Thank-you
in advance. Frank
-
Re: Populating a ComboBox from a Dbase
Frank,
Without actually doing your homework for you (in which case you'd still be
at the same point you are now...), here's one approach to get you started:
1) You need to connect to your database.
2) You need to query the database for the info to populate the combo box.
3) You need to loop through the query's resultset, adding each value returned
into the combo box using the AddItem method.
An additional suggestion would be to set up your query so that it returns
only the field you need. There are quite a few examples of how to do parts
of this in the help facility, not all of them good, but at least you can
see the syntax.
By the way, using the database to populate your combo box is a great way
to provide dynamic updates, and reduce the amount of editting your program
must do... If a new row is added to the database, presto, your program loads
it. Since you, the program, put all the data in there in the first place,
you, the program, should understand it.
If you have a specific problem, post the code, along with what you've tried
and where you think the problem lies. We'll try to help you from there.
Craig Brown
"Frank" <fciliberto@aol.com> wrote:
>
>Hello,
> I am VERY new at this so this might seem like a simple problem to most,
>but what I'm trying to do is populate a combo box from a access database
>automaticaly when the form is loaded. It shouldn't be more than 3 - 4 lines
>of code but I can't find it anywhere and need it for a school project.
Thank-you
>in advance. Frank
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks