OpenConn()


     Dim qqttyy As Integer = Val(ListView1.SelectedItems(0).SubItems(3).Text)
     Dim codee As String = ListView1.SelectedItems(0).SubItems(1).Text

     OleDa.UpdateCommand.CommandText = "UPDATE Inventry SET QTY = QTY -'" & qqttyy & "'WHERE CODE ='" & codee & "'"
     OleDa.UpdateCommand.ExecuteNonQuery()
CloseConn()

I'm not up on data bound controls so I can't speak to that, but the query shouldn't have single quotes around numeric fields. Try

"UPDATE Inventry SET QTY = QTY - " & qqttyy & " WHERE CODE = " & codee

Also, you needed a space before "WHERE". If CODE is char instead of numeric then use

"UPDATE Inventry SET QTY = QTY - " & qqttyy & " WHERE CODE = '" & codee & "'"

its giving message
Object reference not set to an instance of an object.

Let's try this again. On which of the following lines do you get the error?

OpenConn()

Dim qqttyy As Integer = Val(ListView1.SelectedItems(0).SubItems(3).Text)
Dim codee As String = ListView1.SelectedItems(0).SubItems(1).Text

OleDa.UpdateCommand.CommandText = "UPDATE Inventry SET QTY = QTY -'" & qqttyy & "'WHERE CODE ='" & codee & "'"
OleDa.UpdateCommand.ExecuteNonQuery()

CloseConn()

on this line, i am geting error
& message is : Object reference not set to an instance of an object.

    OleDa.UpdateCommand.CommandText = "UPDATE Inventry SET QTY = QTY -'" & qqttyy & "'WHERE CODE ='" & codee & "'"
This article has been dead for over six months. Start a new discussion instead.