Click to See Complete Forum and Search --> : WHERE syntax problem??


StuA
04-05-2004, 12:38 PM
I believe my problem is associated with date compare?? Here's the error:

Microsoft VBScript runtime error '800a01f4'
Variable is undefined: 'datetime'

Here's the code:

Dim myDrawer,myBegCash,myCashIn,myCashOut,myEndCash,mytotalcash,mylongshort,myBalancingDate,myInputBy
myDrawer = Request.Form("Drawer")
myBegCash = Request.Form("BegCash")
myCashIn = Request.Form("CashIn")
myCashOut = Request.Form("CashOut")
myEndCash = Request.Form("EndCash")
mytotalcash = Request.Form("totalcash")
mylongshort = Request.Form("longshort")
myBalancingDate = Request.Form("BalancingDate")
myInputBy = Request.Form("InputBy")

myID1=Request.Form("Drawer")
myID2=Request.Form("BalancingDate")


mySQL1 = "UPDATE cashdrawer SET begcash = '"&_
Request.Form("BegCash") &_
"',cashin = '"&Request.Form("CashIn") &_
"',cashout = '"&Request.Form("CashOut") &_
"',endcash = '"&Request.Form("EndCash") &_
"',totalcash = '"&Request.Form("totalcash") &_
"',longshort = '"&Request.Form("longshort") &_
"',datetime = '"&Request.Form("BalancingDate") &_
"',inputby = '"&Request.Form("InputBy") &_
"' WHERE drawer = " & myID1 AND [datetime] = " & myID2 "

Using SQL database
Thank you in advance for any help.
This is my first posting. Hopefully everything is entered correectly.

simflex
04-05-2004, 02:08 PM
I am curious, why are you using datetime as a field?

It won't work with sql server to start with.

Second, this syntax is wrong anyway:

"' WHERE drawer = " & myID1 AND [datetime] = " & myID2 "

I see a single quote (') at the beginning of that line but none at end and besides, ..well.

U need something like:
" where drawer = " & myID1 & " AND date field = '" & myID2& "' "

StuA
04-05-2004, 02:38 PM
Thanks for your help. This is workinhg now:

WHERE drawer = '" & myID1 & "' AND [datetime] = '" & myID2 & "'"