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()
hhm_pro992
0
Newbie Poster
Recommended Answers
Jump to PostYou 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 …
All 3 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.