sql = "select * from tablename where orderid="รหัสสั่งซื้อ
cmd = New OleDbCommand(Sql, Conn)
reader = cmd.ExecuteReader
If reader.HasRows Then
while reader.read()
if reader("Receivable") = "0" then
sql = "update Orders set StatusOrder=2 where orderid="รหัสสั่งซื้อ" and productid=reader("productid")
else
sql = "update Orders set StatusOrder=1 where orderid="รหัสสั่งซื้อ" and productid=reader("productid")
end if
cmd = New OleDbCommand(Sql, Conn)
cmd.ExecuteNonQuery()
end while
end if
update Orders set
StatusOrder = (
select StatusOrder =
case count(*)
when 0 then 2
else 1
end
from OrderDetails
where Receivable > 0
and OrderID = 'PO550004'
)
where OrderID = 'PO550004'