Adding fields from a database to a listbox

bouki's Avatar, Join Date: Apr 2010
Go4Expert Member
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()
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
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()
.........
0
bouki's Avatar, Join Date: Apr 2010
Go4Expert Member
Thanks alot