Forums
This topic is locked
CharonCart - Stock control - for two tables??
Posted 06 Jul 2002 23:26:46
1
has voted
06 Jul 2002 23:26:46 Gretarsson Ingi Orn posted:
Hi.. I am wondering how I can use the stock control server behavior to update two tables. I am building a commercial site that sells shoes and it has one product table witch contains the productID field and the TotalQuantity for that shoetype.I also have a ProductSize table witch also contains the the same productID and the Quantity for each shoe size of that ProductID. Now what I need to do is to subtract the Product.TotalQuantity field by the the relevant quantity of the cart (Witch the stock control behavior does) and also I need to subtract the same quantity per shoe size in the ProductSize.Quantity field.I tried doing this:
if Request("CC_OrderInsert"

set UpdateStock = Server.CreateObject("ADODB.Command"

UpdateStock.ActiveConnection = MM_connSS_STRING
isColNumeric=false
for i=0 to ubound(CCcart,2)
if CCcart(CC_ProductID,i) <> "" then
if isColNumeric then
UpdateStock.CommandText = "UPDATE Vorutafla SET Magn = Magn - " & CCcart(CC_Quantity,i) & " WHERE Vorunumer = " & CCcart(CC_ProductID,i)
UpdateStock.CommandText = "UPDATE Voruvidauki SET Magn = Magn - " & CCcart(CC_Quantity,i) & " WHERE Vorunumer = " & CCcart(CC_ProductID,i) & " AND ProductSize = " & CCcart(CC_Staerd,i)
else
UpdateStock.CommandText = "UPDATE Vorutafla SET Magn = Magn - " & CCcart(CC_Quantity,i) & " WHERE Vorunumer = '" & CCcart(CC_ProductID,i) & "'"
UpdateStock.CommandText = "UPDATE Voruvidauki SET Magn = Magn - " & CCcart(CC_Quantity,i) & " WHERE Vorunumer = " & CCcart(CC_ProductID,i) & " AND ProductSize = " & CCcart(CC_Staerd,i) & "'"
end if
UpdateStock.Execute
end if
next
UpdateStock.ActiveConnection.Close
end if
%>
But I get an error message
HTTP 500.100 - Internal Server Error - ASP error
Internet Information Services
--------------------------------------------------------------------------------
Technical Information (for support personnel)
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error in string in query expression 'Vorunumer = kk-00001 AND Productsize = 44''.
/SS/checkoutb.asp, line 89
Browser Type:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
Page:
POST 92 bytes to /Ss/Checkoutb.asp
POST Data:
Submit=Sta%F0festa+P%F6ntun&CC_OrderInsert=1&SubTotal=13200&IpAddress=127.0.0.1&CustomerID=2
What am I doing wrong here??
I´m fairly new to SQL
Can any1 help me sort this out??
Ingi Orn Gretarsson