Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27412

VS 2010 Listview help needed

$
0
0
I am confused being a relatively new user to vb.net. Why my listview is not amending the value in the list? If I may, so I have a correct working of how listview displays its data from database. I have a general question in addition to my code problem.

I have five columns in my listview (0-4). Am I correct in saying that if my access database contained say 10 fields but I only needed to display five of them but one of them was field (9), then would code the list like my code below, which is not changing the value and will only display the list if I remove the 'else' statement.

What is the error? Many thanks




Code:

oledbCnn.ConnectionString = My.Settings.storageConnectionString
            oledbCnn.Open()

            'drcount = Convert.ToInt32(dr("RowCount"))

            sql = "Select TOP 100 * from Requests ORDER BY [Date-time received] DESC"
            Debug.Print(sql)
            Dim oledbCmd As OleDbCommand = New OleDbCommand(sql, oledbCnn)


            Using dr = oledbCmd.ExecuteReader()


                'clear items in the list before populating with new values
                'lvRequests.Items.Clear()

                While dr.Read()
                    If dr.HasRows Then
                        Dim LVI As New ListViewItem
                   
                        With LVI
                            .Text = dr(0).ToString()
                            .UseItemStyleForSubItems = False
                            .SubItems.Add(CDate(dr(5)).ToShortDateString())
                            .SubItems.Add(dr(1).ToString())
                            .SubItems.Add(dr(3).ToString())
                            If dr(3).ToString = "D" Then
                                .SubItems(3).Text = "Destroyed"
                            ElseIf dr(3).ToString = "O" Then
                                .SubItems(3).Text = "Out"
                            ElseIf dr(3).ToString = "I" Then
                                .SubItems(3).Text = "Intake"
                            End If
                            .SubItems.Add(dr(9).ToString())
                            If dr(9).ToString = "DEMO" Then
                                .SubItems(LVI.SubItems.Count - 1).Text = "Done" <--- Not Amending

                            End If
                        End With
                        lvRequests.Items.Add(LVI)

                        lvcount += 1

                    End If

                End While
            End Using


Viewing all articles
Browse latest Browse all 27412

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>