i dont know how to access individual rows in the listview ..kindly help me

You can iterate through the rows by

For Each item As ListViewItem In ListView1.Items
    'code here
Next

and you can access the columns (zero relative) from within that loop by

item.SubItems(0).Text
item.SubItems(1).Text
etc.

Convert the values to numeric as appropriate

the code i tried gives me errors;
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Try
            Dim i, c As String
            Dim a, b, d As String
            i = ListView1.Items.Count - 1
            While i >= 0
                a = ListView1.Items.Item(i).Text
                b = ListView1.Items.Item(i).SubItems.Item(1).Text
                c = ListView1.Items.Item(i).SubItems.Item(2).Text
                d = ListView1.Items.Item(i).SubItems.Item(2).Text


                Dim QUERY As String
                QUERY = "INSERT INTO sales(id,item name,item description,price,quality,total price)VALUES ('" + a + "','" + b + "','" + c + "')"
                'EXECUTEQUERY(QUERY)
                MsgBox("saved")
            End While
        Catch eEndEdit As System.Exception
            System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
        End Try


    End Sub
End Class        


        Dim i, c As String
        Dim a, b, d As String
        i = ListView1.Items.Count - 1
        While i >= 0
            a = ListView1.Items.Item(i).Text
            b = ListView1.Items.Item(i).SubItems.Item(1).Text
            c = ListView1.Items.Item(i).SubItems.Item(2).Text
            d = ListView1.Items.Item(i).SubItems.Item(2).Text


            Dim QUERY As String
            QUERY = "INSERT INTO sales(id,item name,item description,price,quality,total price)VALUES ('" + a + "','" + b + "','" + c + "')"
            EXECUTEQUERY(QUERY)
            MsgBox("saved")
        End While
    Catch eEndEdit As System.Exception
        System.Windows.Forms.MessageBox.Show(eEndEdit.Message)
    End Try


End Sub

End Class

how do add the total of items in listview column and display the result in a text box

I was under the impression this was a math problem. You are probably running into problems with your field names (hard to say since you didn't post the error messages). Either rename your fields to eliminate the blanks (delete or replace with underscore) or enclose your field names in "[" and "]". Also, the number of items in the field list must match the number of values in the VALUES clause. In your queries you specified six fields but only three values.

Your while loop won't work. There is no way for it to terminate because you do not change the value of i. Use the form I suggested earlier (for-each).

Edited 3 Years Ago by Reverend Jim

This article has been dead for over six months. Start a new discussion instead.