目前我有将记录插入到 tbl_order 的更新代码。现在我实现了库存部分。我需要系统可以在订单完成后从库存中减去数量。
我正在考虑 INSERT (Subtract (od_qty-tbl_inventory.inv_qty)) 但我不知道在这种情况下 SQL 语句将如何。所以请你帮忙。谢谢
下面是我当前将数据插入到 tbl_order 的更新代码。
<%
dim od_total, cal_total, od_qty
cust_id = request.querystring("cust_id")
bill_id = request.querystring("bill_id")
pd_id = request.querystring("pd_id")
od_price = request.querystring("od_price")
od_qty = request.querystring("od_qty")
od_qty_unit = request.querystring("od_qty_unit")
date_current = date
od_total = od_price * od_qty
Dim conn ' ADO connection
Dim rstSimple ' ADO recordset
Dim strDBPath ' path to our Access database (*.mdb) file
Dim bill_total
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("../database/tkp.mdb"))
set rs=Server.CreateObject("ADODB.recordset")
' Next, the script inserts the form inputs retrieved from the querystring into the database table:
sql="INSERT INTO tbl_order (cust_id,bill_id,pd_id,od_price,od_qty,od_qty_unit,od_total)"
sql=sql & " VALUES "
sql=sql & "(" & cust_id & ","
sql=sql & "'" & bill_id & "',"
sql=sql & "'" & pd_id & "',"
sql=sql & "" & od_price & ","
sql=sql & "" & od_qty & ","
sql=sql & "'" & od_qty_unit & "',"
sql=sql & "" & od_total & ")"
'response.write sql
on error resume next
conn.Execute sql
if err<>0 then
Response.Write("No update permissions!") 'ae_name field is primary key so new record not inserted if name pre-exists in table
else
'Response.Write("<h3> Record added</h3>")
end if
rstSimple.Close
Set rstSimple = Nothing
conn.Close
Set conn = Nothing
%>