Home All Groups Group Topic Archive Search About

Update command to update field

Author
24 Apr 2010 2:27 AM
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

Author
24 Apr 2010 4:42 AM
Jason Keats
Jay wrote:
Show quoteHide quote
> 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.
Author
25 Apr 2010 1:31 AM
Jay
Thank you

Show quoteHide quote
"Jason Keats" <jke***@melbpcDeleteThis.org.au> wrote in message
news:#DNTJi24KHA.420@TK2MSFTNGP02.phx.gbl...
> Jay wrote:
>> 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.
>
>
Author
25 Apr 2010 9:03 AM
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)

Show quoteHide quote
"Jay" <jpab***@gmail.com> wrote in message
news:epTXzW14KHA.3824@TK2MSFTNGP04.phx.gbl...
> 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
>