views:

66

answers:

1

I am getting stuck on this problem. It seems simple but for some reason im having trouble.

Here is what I have of the following:

 Try
        cn = New OleDbConnection("Provider=microsoft.Jet.OLEDB.4.0;Data Source=G:\Sean\BMSBonder3_0.mdb;")
        cn.Open()
        str = "Select Distinct BonderIdentifier From [Session]"
        cmd = New OleDbCommand(str, cn)
        dr = cmd.ExecuteReader

        dr.Read()
        If dr.Item(0).ToString <> "" Then
            ListBox1.Items.Add(dr.Item(0))
        End If

        cn.Close()
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

This works to get only one of the values. Actually the last. how can i get all of them?

Sorry for the newb question. Searching didnt help too much.

+2  A: 

You need to use a While loop to repeatedly execute your code until dr.Read() returns False.
For example:

While dr.Read()
    If dr.Item(0).ToString <> "" Then
        ListBox1.Items.Add(dr.Item(0))
    End If
Wend
SLaks
Oh thats right...thanks...sorry for the stupid question
Sean P