Update command to update field

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
 
J

Jason Keats

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

Jay

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

Cor Ligthert[MVP]

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top