Hello everyone--
I've tried many of the things I've found searching the newsgroups in
trying to store 2 fields to a combobox and use displaymember and
valuemember but nothing is working. Here is my code:
Dim strSQL As String
Dim dataAdapt As New OleDbDataAdapter
Dim cmd As New OleDbCommand
Dim rst As New DataSet
Dim x As Integer
strSQL = _
"SELECT RaceID, Description " & _
"FROM tblRace"
cmd.Connection = cnDB
cmd.CommandType = CommandType.Text
cmd.CommandText = strSQL
dataAdapt.SelectCommand = cmd
cboRace.DataSource = rst.Tables("tblRace")
cboRace.DisplayMember = "Description"
cboRace.ValueMember = "RaceID"
dataAdapt.Fill(rst, "tblRace")
Nothing shows up in my combobox when I use the above code. If I use
the following code, I do get my combobox populated:
For x = 0 To rst.Tables("tblRace").Rows.Count - 1
cboRace.Items.Add(rst.Tables("tblRace").Rows(x)("D escription"))
Next
This isn't what I want though because I need to capture the RaceID that
is selected. Any ideas of what I'm doing wrong?
Thanks.
Molly J. Fagan
Oklahoma Foundation for Medical Quality