Hello,
I have a database-table with a colum wich contains ID-numbers as integers. These ID-numbers in this column is set as primary keys.
Also I have a listbox which contains names from another column in the same database-table.
I now want to set a variable (as integer) which contains this primary key.
So if you select the name in the listbox the variable gets the primary key number from the name-item.
Something like this:
CODE
Private Sub MyListBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim ID as integer
ID = MyListBox.SelectedValue
End Sub
I have set in the propertybox from the listbox the selectedvalue as my primary-key column from the database. This must be correct!!
When the integer-variable ID is set i want to use this number (integer) for my selectquery:
CODE
Dim strsql As String = "select Name where MyID=ID"
But when I try this I get the folowing error-code:
Column 'ID' is constrained to be unique. Value '9' is already present.
What to do about this?? I'm in the dark here!