Adding fields from a database to a listbox

Discussion in 'Visual Basic ( VB )' started by bouki, Mar 5, 2011.

  1. bouki

    bouki New Member

    Joined:
    Apr 9, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    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()
    
     
  2. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    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()
    .........
    
     
  3. bouki

    bouki New Member

    Joined:
    Apr 9, 2010
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    Thanks alot
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice