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

VS 2010 Property 'item' is 'Read Only' error

$
0
0
I am getting the above error when I run my code. I think this is because the DataReader is Read-Only and therefore unable to amend the value.

As a new user still getting to grips with vb.Net coming from php/mysql background, can someone show me the correct way to code this please or offer an alternative method. Many thanks

Code:

While dr.Read()
        If dr.HasRows Then

          lvRequests.Items.Add((dr(0)).ToString()).UseItemStyleForSubItems = False
          lvRequests.Items(lvRequests.Items.Count - 1).SubItems.Add(CDate(dr(5)).ToShortDateString())
          lvRequests.Items(lvRequests.Items.Count - 1).SubItems.Add(dr(1).ToString())
        With lvRequests.Items(lvRequests.Items.Count - 1).SubItems.Add(dr(3).ToString())
            If dr(3) Is "D" Then   
                dr(3) = "destroyed"  <--- ERROR

            ElseIf dr(3) Is "O" Then
                dr(3) = "out"        <--- ERROR

            End If

        End With

          lvRequests.Items(lvRequests.Items.Count - 1).SubItems.Add(dr(9).ToString())

          lvcount += 1
        End If

    End While


Viewing all articles
Browse latest Browse all 27329

Trending Articles



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