hello,I have a simple problem with regards to my project. I'm doing a simple glossary. In my form, I have a textbox to search a word from the listbox, of course a listbox(lstWord ) populated with words stored in the database, and another textbox(txtDefi ne) to display the meaning of the selected word from the listbox. My problem is that when I select a word/item from the listbox it only displays the value of the second item onward and nothing displays when I select the first item. In the table in my database (example only):
word_id word definition
1 sample abc
2 sample1 def
3 sample2 xyz
..so my listbox displays sample,sample1, sample2. When I select sample the value should be abc but nothing appears,when I select sample1 its value displayed is abc, if sample2 the value became xyz..this is my code:
how can I fix this?, any help would be greatly appreciated. thanks in advance
word_id word definition
1 sample abc
2 sample1 def
3 sample2 xyz
..so my listbox displays sample,sample1, sample2. When I select sample the value should be abc but nothing appears,when I select sample1 its value displayed is abc, if sample2 the value became xyz..this is my code:
Code:
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim myCmd As New MySqlCommand
Dim myReader As MySqlDataReader
Call Connect()
With Me
STRSQL = "select definition from glossary where word_id =" & lstWord.SelectedIndex
myCmd.Connection = myConn
myCmd.CommandText = STRSQL
myReader = myCmd.ExecuteReader
While (myReader.Read())
txtDefine.Text = myReader("definition")
End While
myReader.Close()
myConn.Close()
End With
End Sub
Comment