Adding fields from a database to a listbox

Go4Expert Member
5Mar2011,09:30   #1
bouki's Avatar
I want to add all the Records in my database in a list box (Book name), However nothing is adding to the listbox

Code:
cmd.Connection = cn
        cmd.CommandType = CommandType.Text
        cmd.CommandText = " select BookName from Book "
        rdr = cmd.ExecuteReader
        Do While rdr.Read
            cbdvuser.Items.Add(rdr.Item("BookName"))
        Loop
        cn.Close()
Pro contributor
6Mar2011,05:54   #2
virxen's Avatar
inside the while loop
add a msgbox command to show you what it reads


something like this i mean
Code:
..........
 Dim reader As SqlDataReader
  reader = Command.ExecuteReader()
  While reader.Read()
    MsgBox(reader.Item(0))
  End While
  reader.Close()
.........
Go4Expert Member
6Mar2011,08:58   #3
bouki's Avatar
Thanks alot