0
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()
2
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by hhm_pro992
0

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 & "'"
0

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

0

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()
0

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 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.