System.Data.DataRowView showing in combobox instead of actual values

FryDay_Boy

Newcomer
Joined
Jun 10, 2005
Messages
3
Hello all pros and gurus, I have some problems with the combobox, I tried to populate it from an access database but instead I get System.Data.DataRowView in the combobox -_-"

The following is the code :

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connstring As String
Dim cconnection As OleDbConnection
Dim DistrictAdapter As OleDbDataAdapter
Dim ds_name As New DataSet

connstring = .................
cconnection = New OleDbConnection(connstring)
cconnection.Open()

DistrictAdapter = New OleDbDataAdapter("Select * from [resource master list] where [last name] = '" & TextBox1.Text & "'", cconnection)
DistrictAdapter.Fill(ds_name, "namelor")

ComboBox1.DisplayMember = "first name"

ComboBox1.ValueMember = "employee id"

ComboBox1.DataSource = ds_name.Tables("namelor")

cconnection.Close()
cconnection = Nothing



End Sub

Please HELP ME!!!! Thank you very much
 
Try it in this order:

Visual Basic:
ComboBox1.DataSource = ds_name.Tables("namelor")
ComboBox1.DisplayMember = "first name"
ComboBox1.ValueMember = "employee id"
 
penfold69 said:
Try it in this order:

Visual Basic:
ComboBox1.DataSource = ds_name.Tables("namelor")
ComboBox1.DisplayMember = "first name"
ComboBox1.ValueMember = "employee id"

Hello Penfold69, thank you for your reply but I get the following error :

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: Could not bind to the new display member.


please advise
 
You might have to wrap the DisplayMember and ValueMember in []s, like:

ComboBox1.DisplayMember = "[first name]"
ComboBox1.ValueMember = "[employee id]"

Try that!

B.
 
Back
Top