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

Recommended Answers

All 6 Replies

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.

i, try bouth lines

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