Link to home
Start Free TrialLog in
Avatar of Matrix1000
Matrix1000

asked on

How to fill listbox from SQL query

I'm writing a small VB.NET app.
How would I fill a list box using an SQL query?
I have a listbox that I need to populate with data from SQL.
I have a username/password/SQL address. SQL query would be (select StockNumber from dbo.VehicleMaster)

Would appreciate a code sample :)

Thanks!
Avatar of Jeff Certain
Jeff Certain
Flag of United States of America image

Is your database SQL server or something else?
ASKER CERTIFIED SOLUTION
Avatar of Brian Crowe
Brian Crowe
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
BriCrowe ,

Nice hijack.
Avatar of Matrix1000
Matrix1000

ASKER

BriCrowe's example worked perfectly right off the bat.

Chaosian, VB.net had issues with
        lstStocknumberList.DataSource = myTable
        lstStocknumberList.DataTextField = StockNumber
        lstStocknumberList.DataValueField = StockNumber
        lstStocknumberList.DataBind()
 saying that 'DataTextField' etc is not a member of System.Windows.forms.Listbox.
Thanks for trying tho :)