Hello!
I am makeing inventry program for my SHOP,
When Button1 clicked, listview all items will UPDATE, listview coloum 3(QUANTITY) will SUBTRACT from ms access quantity.
Please help me........

Private Sub ButtonAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

        Try
            Call OpenConnection()
            Dim v1 As Integer
            Dim v2 As Integer = ListView1.Items(0).SubItems(3).Text
            Dim ans As Integer


           Dim SQLQuery As String = "Update([INVENTRY] Where [QTY]" = v1 )
            ans = v1 - v2

            With OleDa

                .UpdateCommand = New OleDb.OleDbCommand()
                .UpdateCommand.CommandText = "UPDATE [INVENTRY] SET [ItemCode] = @ItemCode , [ItemName] = @ItemName , [QTY] = @QTY , [SalePrice] = @SalePrice , [PurchasePrice] = @PurchasePrice WHERE (EmployeeID = ?)"
                .UpdateCommand.Connection = OleCn
                .UpdateCommand.Parameters.Add("@ItemCode", OleDb.OleDbType.VarWChar, 50, "ItemCode").Value = ListView1.Items(0).Text
                .UpdateCommand.Parameters.Add("@ItemName", OleDb.OleDbType.VarWChar, 50, "ItemName").Value = ListView1.Items(0).SubItems(1).Text
                .UpdateCommand.Parameters.Add("@QTY", OleDb.OleDbType.VarWChar, 50, "QTY").Value = ans
                .UpdateCommand.Parameters.Add("@SalePrice", OleDb.OleDbType.VarWChar, 50, "SalePrice").Value = ListView1.Items(0).SubItems(3).Text
                .UpdateCommand.Parameters.Add("@PurchasePrice", OleDb.OleDbType.VarWChar, 50, "PurchasePrice").Value = ListView1.Items(0).SubItems(4).Text



            End With
            Call CloseConnection()
            MsgBox("Record(s) has been Updated...", MsgBoxStyle.Information, "Record(s) Updated...")
            Me.Close()
        Catch ex As Exception
            MsgBox("Unable to update record(s), Employee ID already exist, please enter another Employee ID...", MsgBoxStyle.Exclamation, "Attention...")
            MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Error...")
            Call CloseConnection()

        End Try


    End Sub

Recommended Answers

All 2 Replies

on line 16 you should have

[QTY]=[QTY]-@QTY

however it looks like the employeeId is the primary key to Inventory file which seems somewhat strange.

Erroe Message is showing
Conversion from string "Update([Employee][LastName]) = " to type
'Double' is not valid.

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.