datavaluefield is supposed to be set to the name of the field. Your code
assigns to it the value of the field. And anyway, datavaluefield is used
only in databinding and you are not using any databinding, you are adding
items programatically.
You should do something like
ListBox1.Items.Add(New ListItem (NameDataReader.GetValue(0) & " " &
NameDataReader.GetValue(1), NameDataReader.GetValue(2)))
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"l7alabeh" <l7******@gmail.comwrote in message
news:11*********************@k70g2000cwa.googlegro ups.com...
This is the code:
Sub ListBoxBind()
connstrconf.ConnectionString = strcnnconf
Dim NameDataReader As OleDbDataReader
Dim NameOleDbCommand As OleDbCommand
NameOleDbCommand = New OleDbCommand("select first_name,
last_name, dbid from cfg_person", connstrconf)
connstrconf.Open()
NameDataReader = NameOleDbCommand.ExecuteReader()
Do While (NameDataReader.Read())
ListBox1.Items.Add(NameDataReader.GetValue(0) & " " &
NameDataReader.GetValue(1))
ListBox1.datavaluefield = NameDataReader.GetValue(2)
Loop
NameDataReader.Close()
connstrconf.Close()
End Sub