I have a combo box that is filled from a database. The connection seems to work all right and what I "SEE" when the form loads is correct..... However, the value member is not what I expect it to be.
Here's the code:
The problem is that the value member is always "UnitMeasure". Description and UnitMeasure are fields in the table indicated. Here's the code that leads me to think there's an error:
Am I doing something wrong here??
Thanks in advance for your help.
Here's the code:
Code:
Private Sub SetUpWorkItemsComboBox()
Dim strDBLocation As String
strDBLocation = My.Settings.DatabaseLocation
Dim conn As New OleDb.OleDbConnection
conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source = " & strDBLocation
Dim da As New OleDb.OleDbDataAdapter("SELECT * FROM tblWorkItems ORDER BY Item_ID", conn)
da.Fill(m_DataSet)
Me.WorkItemComboBox.DataSource = m_DataSet.Tables(0)
Me.WorkItemComboBox.ValueMember = "UnitMeasure"
Me.WorkItemComboBox.DisplayMember = "Description"
m_FormLoaded = True
End Sub
The problem is that the value member is always "UnitMeasure". Description and UnitMeasure are fields in the table indicated. Here's the code that leads me to think there's an error:
Code:
Private Sub WorkItemComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles WorkItemComboBox.SelectedIndexChanged
Dim strItem As String
strItem = WorkItemComboBox.Text
If m_FormLoaded = True Then
MsgBox(strItem & vbNewLine & WorkItemComboBox.ValueMember.ToString)
End If
End Sub
Am I doing something wrong here??
Thanks in advance for your help.