Load values of a comboBox from a TableAdapter

lanz80

New member
Joined
May 5, 2010
Messages
1
Programming Experience
Beginner
Hi,

I would like to how I can load a set of values in a comboBox from a TableAdapter. I have the tableAdapter method to read the data , (in this case GetDataByStreet)--> Me.StreetsTableAdapter.GetDataByStreet()

But I don't know how to assign the sentence to the comboBox, in order to load the data set in it.

I have created this code to prove:

VB.NET:
StreetCombo.DisplayMember = "AreaClasification"
StreetCombo.ValueMember = "AreaClasification"
StreetCombo.DataSource = Me.StreetTableAdapter.GetDataByStreet()

But It doesn´t work because only fills the first index of the comboBox, but not the following values.


Thanks with anticipation.

Regards
 
Last edited:
Surely your valueMember shouldn't be the same name as the displaymember? Databases won't allow for 2 columns with the same name.

Either that's a typo on this website, or it's a typo in your programming.
Should it be
AreaClasificationID (vm)
AreaClasification (dm)
?

I don't think it matters but I'd change the code around so .DataSource is first, then the others.
 
You use your tableadapter to fill a datatable, you then assign the datatable to your combobox not your dataadapter.
 
Mmm.. no, technically the code is correct.. If the combo contains only one item, it's because the datatable returned from the GetDataByStreet call only contained one row.

Debug the app, and put this line in, then a breakpoint after it:

Dim dt as DataTable = Me.StreetTableAdapter.GetDataByStreet()

Now point to "dt" with your mouse
A tooltip appears
In the tooltip there is a magnifying glass
Click on the magnifying glass
 
Back
Top