| | |
sql query updating problem
![]() |
•
•
Join Date: Jul 2005
Posts: 18
Reputation:
Solved Threads: 0
I'm creating a sales invoice order form and whenever a purchase is made, the quantity of a certain product ordered is deducted from the product database. how do i do that? I am using this sql query to get the product details input from vb to the database.
SELECT Invoice_Detail.[InvoiceNo], Invoice_Detail.Product_Code, Items.Description, Invoice_Detail.Qty, Invoice_Detail.Price, Invoice_Detail.Discount_Per, Items.[Sales_Price], ([Qty]*([Price]-[Price]*[DISCOUNT_PER]/100)) AS inv_amount
FROM Items INNER JOIN Invoice_detail1 AS invoice_detail ON Items.[Product_Code] = Invoice_detail.Product_Code;
is there a way to add an extra syntax in there to update the products table to reflect the new quantity? thanks!
SELECT Invoice_Detail.[InvoiceNo], Invoice_Detail.Product_Code, Items.Description, Invoice_Detail.Qty, Invoice_Detail.Price, Invoice_Detail.Discount_Per, Items.[Sales_Price], ([Qty]*([Price]-[Price]*[DISCOUNT_PER]/100)) AS inv_amount
FROM Items INNER JOIN Invoice_detail1 AS invoice_detail ON Items.[Product_Code] = Invoice_detail.Product_Code;
is there a way to add an extra syntax in there to update the products table to reflect the new quantity? thanks!
Well what I would suggest, to make things easier, SELECT the values from the DB and have them stored in a variable on the VB side, then do your calculations, and post the results back to the DB.
Or even better, create a Stored Procedure which you pass the variables into, and have the DB do the calculations and run the UPDATE sql statement to update the data.
Hope this helps..
Or even better, create a Stored Procedure which you pass the variables into, and have the DB do the calculations and run the UPDATE sql statement to update the data.
Hope this helps..
![]() |
Similar Threads
- sql query problem with MS Access and C# (C#)
- how to delete duplicate record in a table by using SQL query (MS SQL)
- SQL query problem with WHERE clause (ASP)
- Javascript array from sql query (JSP)
- Please help me out with MySQL query (MySQL)
- PHP/SQL query help (PHP)
- Retreiving variables from a sql query into a form (PHP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: How to convert wav to mp3 using VB?
- Next Thread: Setting Timer/Clock Precision
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





