Update command to update field

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

In sql server I can run the following query command to update QtyOnPO field.

UPDATE ItemsDetails
SET QtyOnPO = QtyOnPO + 1
WHERE (ItemDetailID = 1)

This will add 1 to QtyOnPO field.

In VB.NET how can I use this?

The following is my code but it gives an error "Name 'QtyOnPO' is not
declared".

ExecNonQuery("UPDATE Pricing SET QtyOnPO = " & QtyOnPO +
row.Cells(Me.Qty.Index).Value & " WHERE ItemDetailID = " & intItemDetailID)

Please help
 
Jay said:
In sql server I can run the following query command to update QtyOnPO
field.

UPDATE ItemsDetails
SET QtyOnPO = QtyOnPO + 1
WHERE (ItemDetailID = 1)

This will add 1 to QtyOnPO field.

In VB.NET how can I use this?

The following is my code but it gives an error "Name 'QtyOnPO' is not
declared".

ExecNonQuery("UPDATE Pricing SET QtyOnPO = " & QtyOnPO +
row.Cells(Me.Qty.Index).Value & " WHERE ItemDetailID = " & intItemDetailID)

Please help

Dim sql As String

sql = "UPDATE Pricing SET"
sql &= " QtyOnPO = QtyOnPO + " & row.Cells(Me.Qty.Index).Value
sql &= " WHERE ItemDetailID = " & intItemDetailID

Debug.WriteLine(sql) 'check what you're going to execute

Etc.
 
Thank you

Jason Keats said:
Dim sql As String

sql = "UPDATE Pricing SET"
sql &= " QtyOnPO = QtyOnPO + " & row.Cells(Me.Qty.Index).Value
sql &= " WHERE ItemDetailID = " & intItemDetailID

Debug.WriteLine(sql) 'check what you're going to execute

Etc.
 
So QtyOnPo which has to be a (numeric) field, property or method(returning a
number), is not declared (available) in the method where you use it.

(Most probably it is a not created global field, while you had the intention
to do that)
 
Back
Top