Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use OLEDB Objects to fill listbox from Data Source

Status
Not open for further replies.

CraigBest

Programmer
Aug 1, 2001
545
US
Looking for code advice on how to load a listbox from an OLEDB data table (or similar object). I already have the connection object set up, I have a command object with the SQL select statement. After the data table is filled, I will assign it to a listbox to automatically fill it.

I need a little help in the midle here -- how do I structure the statements to get my data and fill the DataTable object with it?

Thanks in advance

Craig in NJ
 
This should do it for you

Dim conTestTable As New OleDbConnection(conString)
Dim da As OleDbDataAdapter = New OleDbDataAdapter("Select * from myTable", conTestTable)
Dim dt As New DataTable
da.Fill(dt)
ListBox1.Datasource = dt

DotNetDoc
M.C.S.D.
[2thumbsup]
---------------------------------------

Tell me and I forget. Show me and I remember. Involve me and I understand.
- Anonymous Chinese Proverb

-----------------------------------

If you can't explain it simply, you don't understand it well enough.
- A. Einstein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top