Avatar of Mark Lewis
Mark Lewis

asked on 

Problem with doing a calculation in an ASP Update statement

My predecessor programmed our Intranet using ASP ages ago. There's code on a form submittal where it's using an Update statement to take away from the number showing in the database:

myConnString = Application("Flash_ConnectionString")	
Set myConnection = Server.CreateObject("ADODB.Connection")
myConnection.Open myConnString
	
mySql="UPDATE OnHand SET ohnum = ohnum - 1 WHERE ohnum > 0"
  
myConnection.Execute mySQL
myConnection.Close
Set myConnection = Nothing

Open in new window


This works fine but we have since changed things to where the form allows the person to put any number for this item that we still need to subtract from the DB.

To make things easier, I call the value from the form and assign it to the variable s16: s16 = Request.Form("size16")

Then I try to get the Update statement to use my s16 var rather than the static number (mySql="UPDATE OnHand SET ohnum = ohnum - s16 WHERE ohnum > 0") and the web page returns this error:
Microsoft OLE DB Provider for ODBC Drivers error '80040e10'

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.

/flash/Confirm.asp, line 233

Open in new window


Some things I do know:
1. Both ohnum and size16 are a Number data type in the Access DB
2. Via a Response.Write Command, I verified that the variable s16 does carry the correct information.

It's probably some kind of text/number mismatch but I cant seem to figure it out.

I have zero training with ASP so be gentle :)
ASPMicrosoft Access

Avatar of undefined
Last Comment
Gustav Brock

8/22/2022 - Mon