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

fill listbox with Access.mdb data?

P: n/a
Hello,

I am just starting out with VB.net. I need to fill a
listbox with data from an MS Access mdb file.

What I tried was to create/add an ole connection object,
then added an ole adapter object and an command object
(the commandtext is "Select * from table1"), then added a
dataset object. So I got as far as doing something like
this in a button:

oleCmd.Fill(dataset1)

May I ask if someone could explain how to fill the
listbox? I actually, only need data from the first column
of table1. And I admit that I am a little confused with
the oleadapter and command objects. Do I need both?

Many thanks for any help.

Nov 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Cor
Hi Rich,

From this point you can do.
oleCmd.Fill(dataset1)


mylistbox.datasource = dataset1.tables(0)
mylistbox.displaymember = "AnItemFormYourDatabase as in the select"
mylistbox.valuemember="Another item"

Normaly you will show how nice it is filles the listbox.

I hope it goes?

Cor
Nov 20 '05 #2

P: n/a
I haven't tried it in dotnet yet, but I would assume you just set the
ListBox.DataSource = Dataset.Tables("YourTable").Columns("YourColumn"

Sean
Nov 20 '05 #3

P: n/a
Thank you all for your replies. I will try out the
suggestions.

-----Original Message-----
Hello,

I am just starting out with VB.net. I need to fill a
listbox with data from an MS Access mdb file.

What I tried was to create/add an ole connection object,
then added an ole adapter object and an command object
(the commandtext is "Select * from table1"), then added a
dataset object. So I got as far as doing something like
this in a button:

oleCmd.Fill(dataset1)

May I ask if someone could explain how to fill the
listbox? I actually, only need data from the first column
of table1. And I admit that I am a little confused with
the oleadapter and command objects. Do I need both?

Many thanks for any help.

.

Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.