Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Posted
Try it in this order:

 

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

Posted

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

 

ComboBox1.DisplayMember = "[first name]"

ComboBox1.ValueMember = "[employee id]"

 

Try that!

 

B.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...