Issue with finding sql table ID in VB.Net combobox
Posted on 2016-07-18
I have loaded a combobox in VB.Net with the following code:
Dim conn As New SqlConnection(sqlComm)
Dim sSQL As String
sSQL = "SELECT strSelect from tvwSelect order by strSelect"
Dim dbadp As New SqlDataAdapter(sSQL, sqlComm)
Dim dTable As New DataTable
Me.cboRecord.DisplayMember = "strSelect"
Me.cboRecord.ValueMember = "numLeadID"
Me.cboRecord.DataSource = dTable
Catch ex As Exception
conn = Nothing
Now I want to click on an item in the combobox and retrieve the numLeadID number so I can grab that record from the database. I am new to .Net and don't know how to go about this. I tried to see what I was selecting with this code:MsgBox(cboRecord.SelectedValue) but I got an error message. I will supply more info or clarify if necessary.