0
ryan = "Select A.*, B.* from training as A, participant as B where B.partname = '" & TextBox1.Text & "' and A.traincode = 'B.traincode'"

                rs1.CursorLocation = ADODB.CursorLocationEnum.adUseClient
                rs1.Open(ryan, cn, ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic)
                Form11.ListView1.Items.Clear()
                Dim AddItem As ListViewItem
                Do While Not rs1.EOF
                    AddItem = New ListViewItem(rs1.Fields!traincode.Value.ToString)
                    AddItem.SubItems.Add(rs1.B.Fields!title.Value)
                    AddItem.SubItems.Add(rs1.Fields!venue.Value)
                    AddItem.SubItems.Add(rs1.Fields!sdate.Value & "-" & rs1.Fields!edate.Value)
                    Form11.ListView1.Items.Add(AddItem)
                    rs1.MoveNext()
                Loop

there's no error but no data shown in my listview every time i search the correct data. is there a problem on my sql code?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by crapulency
0

hi ryan, I'm a bit rusty on adodb but I've got a feeling recordset.MoveFirst needs to be called before looping through records. Something like this:

With rs1
            'First check there are records
            If Not (.BOF And .EOF) Then
                .MoveFirst()
                Do While Not .EOF
                    'Add your listview stuff
                    .MoveNext()
                Loop
            End If
        End With
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.