Page 1 of 1

TableAdapter.Insert vs. ComboBox1.ValueMember

Posted: Sat Jul 02, 2011 8:48 pm
by NewGuy
Hey

I have a small problem i cant seem to figure out ... I have a form with 1 textbox and 1 combobox. The combobox i setup on the form with "use databound items" and the databound items are :

Datasource : PersonBindingSource
Display member: PersonName
ValueMember : PersonID

I then try to enter info into the table

If u use this: Person_TableAdapter.Insert(1, 1) - It works fine

If i use this: Person_TableAdapter.Insert(Me.TextBox.Text, 1) - It works fine

BUT if i try this ... it fails
Person_TableAdapter.Insert(Me.TextBox.Text, Me.ComboBox1.ValueMember)

Why cant i use "Me.ComboBox1.ValueMember" to get the value of the combobox ? i just need to send the number for ValueMember (PersonID) to the table

This is the error message that pops up after a few seconds:

Conversion from string "PersonID" to type 'Integer' is not valid.

Thank for the help !!

NewGuy