0
OpenConn()

        For Each li As Windows.Forms.ListViewItem In ListView1.Items


            With OleDa

                .UpdateCommand = New OleDb.OleDbCommand()
                .UpdateCommand.CommandText = "UPDATE [Inventry] SET [CODE] = @CODE , [ITEM] = @ITEM , [QTY] = val(QTY) - @QTY , [SPRICE] = @SPRICE , [PPRICE] = @PPRICE WHERE (CODE = ?)"
                .UpdateCommand.Connection = Con
                .UpdateCommand.Parameters.Add("@CODE", OleDb.OleDbType.VarWChar, 50, "CODE").Value = li.SubItems(1)
                .UpdateCommand.Parameters.Add("@ITEM", OleDb.OleDbType.VarWChar, 50, "ITEM").Value = li.SubItems(2).Text
                .UpdateCommand.Parameters.Add("@QTY", OleDb.OleDbType.VarWChar, 50, "QTY").Value = li.SubItems(3).Text
                .UpdateCommand.Parameters.Add("@SPRICE", OleDb.OleDbType.VarWChar, 50, "SPRICE").Value = "@SPRICE"
                .UpdateCommand.Parameters.Add("@PPRICE", OleDb.OleDbType.VarWChar, 50, "PPRICE").Value = "@PPRICE"

                .UpdateCommand.ExecuteNonQuery()

            End With
        Next
        CloseConn()

Edited by mike_2000_17: Fixed formatting

3
Contributors
3
Replies
7
Views
4 Years
Discussion Span
Last Post by Begginnerdev
0

i want , when i click save button then all items in listview will subtract qty from ms access where is code..........

0

You will need a for statment to cycle through the listview.

(This only works where a unique value is present for each entry.) (Like an ID Column)

'This assumes that the CODE field is unique to each database entry!!
For Each li as ListViewItem In ListView1.Items
    With OleDa
        .DeleteCommand = "DELETE FROM table WHERE CODE=@CODE"
        .DeleteCommand.Parameters.Add("@CODE",OleDb.OleDbType.VarWChar, 50, "CODE").Value = li.SubItems(1))
        .DeleteCommand.ExecuteNonQuery()
    End With
Next

Edited by Begginnerdev

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.