Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Why this SQL command doesn't work?


Message #1 by yhuang@c... on Thu, 25 Apr 2002 15:21:22
Hi,

I am trying to update records in my Access database, and having problem 
with this error message:

Error Type:
Microsoft JET Database Engine (0x80040E07)
Syntax error in date in query expression '##'.
/tracking1/stateDraft2.asp, line 27

I had no problem to update one date field, but couldn't make it with two 
fields. The fields are all in Date/time format in Access.

My code:

<%'******* StateDraft2.asp ************

DraftBDate=Request("txtDraftBDate")
DraftTDate=Request("txtDraftTDate")
DraftEDate=Request("txtDraftEDate")

'stateId=Session("stateId")
'statePass=Session("statePass")
stateAbbrev=Session("stateAbbrev")
if stateAbbrev="" then
Response.write "<BR><BR><BR><BR><h2 align=""center""><font color=""Red"">"
Response.write "You must sign in before entering this page!</font></h2)
<BR><BR><BR><BR>"
Response.write "<a href=""Home.htm"">Home</a>"

Else

Set newconn=Server.CreateObject("ADODB.Connection")
newconn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data 
source=e:\web\Tracking1\Tracking1.mdb"

'****This one doesn't work:*****
SQLcmd1="Update PROGRESS set DraftBegin=#" &DraftBDate 
&"#,PreDraftToRegion=#" &DraftTDate& "#,DraftEnd=#" &DraftEDtate& "# where 
stateAbbrev='"&stateAbbrev&"'"

'***This one works: ******
'SQLcmd1="Update PROGRESS set DraftBegin=#" &DraftBDate &"# where 
stateabbrev='"&stateAbbrev1&"'"

newconn.Execute SQLcmd1      '***This is line 27****

%>
...

I Will greatly appreciate your help!

Cindy
Message #2 by Achimwene Dzida <dzidap@y...> on Thu, 25 Apr 2002 07:40:34 -0700 (PDT)
Let me give it a try

I think there is a datatype mismatch here. Try to
check what kind of data  you updating into the field
of access.

i assume that you are trying to update a date field by
putting into it data of type text. Access wont accept
that.


--- yhuang@c... wrote:
> Hi,
> 
> I am trying to update records in my Access database,
> and having problem 
> with this error message:
> 
> Error Type:
> Microsoft JET Database Engine (0x80040E07)
> Syntax error in date in query expression '##'.
> /tracking1/stateDraft2.asp, line 27
> 
> I had no problem to update one date field, but
> couldn't make it with two 
> fields. The fields are all in Date/time format in
> Access.
> 
> My code:
> 
> <%'******* StateDraft2.asp ************
> 
> DraftBDate=Request("txtDraftBDate")
> DraftTDate=Request("txtDraftTDate")
> DraftEDate=Request("txtDraftEDate")
> 
> 'stateId=Session("stateId")
> 'statePass=Session("statePass")
> stateAbbrev=Session("stateAbbrev")
> if stateAbbrev="" then
> Response.write "<BR><BR><BR><BR><h2
> align=""center""><font color=""Red"">"
> Response.write "You must sign in before entering
> this page!</font></h2)
> <BR><BR><BR><BR>"
> Response.write "<a href=""Home.htm"">Home</a>"
> 
> Else
> 
> Set newconn=Server.CreateObject("ADODB.Connection")
> newconn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
> 
> source=e:\web\Tracking1\Tracking1.mdb"
> 
> '****This one doesn't work:*****
> SQLcmd1="Update PROGRESS set DraftBegin=#"
> &DraftBDate 
> &"#,PreDraftToRegion=#" &DraftTDate& "#,DraftEnd=#"
> &DraftEDtate& "# where 
> stateAbbrev='"&stateAbbrev&"'"
> 
> '***This one works: ******
> 'SQLcmd1="Update PROGRESS set DraftBegin=#"
> &DraftBDate &"# where 
> stateabbrev='"&stateAbbrev1&"'"
> 
> newconn.Execute SQLcmd1      '***This is line 27****
> 
> %>
> ...
> 
> I Will greatly appreciate your help!
> 
> Cindy


__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/
Message #3 by Martin Lee <access@o...> on Thu, 25 Apr 2002 23:47:21 +0800
Cindy:

have you checked that DraftTDate and DraftEDate contain a date and are not 
empty?

Have experienced this same error message when trying to update a date field 
with a null value.

Martin


At 03:21  4/25/2002 +0000, you wrote:
>Hi,
>
>I am trying to update records in my Access database, and having problem
>with this error message:
>
>Error Type:
>Microsoft JET Database Engine (0x80040E07)
>Syntax error in date in query expression '##'.
>/tracking1/stateDraft2.asp, line 27
>
>I had no problem to update one date field, but couldn't make it with two
>fields. The fields are all in Date/time format in Access.
>
>My code:
>
><%'******* StateDraft2.asp ************
>
>DraftBDate=Request("txtDraftBDate")
>DraftTDate=Request("txtDraftTDate")
>DraftEDate=Request("txtDraftEDate")
>
>'stateId=Session("stateId")
>'statePass=Session("statePass")
>stateAbbrev=Session("stateAbbrev")
>if stateAbbrev="" then
>Response.write "<BR><BR><BR><BR><h2 align=""center""><font color=""Red"">"
>Response.write "You must sign in before entering this page!</font></h2)
><BR><BR><BR><BR>"
>Response.write "<a href=""Home.htm"">Home</a>"
>
>Else
>
>Set newconn=Server.CreateObject("ADODB.Connection")
>newconn.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data
>source=e:\web\Tracking1\Tracking1.mdb"
>
>'****This one doesn't work:*****
>SQLcmd1="Update PROGRESS set DraftBegin=#" &DraftBDate
>&"#,PreDraftToRegion=#" &DraftTDate& "#,DraftEnd=#" &DraftEDtate& "# where
>stateAbbrev='"&stateAbbrev&"'"
>
>'***This one works: ******
>'SQLcmd1="Update PROGRESS set DraftBegin=#" &DraftBDate &"# where
>stateabbrev='"&stateAbbrev1&"'"
>
>newconn.Execute SQLcmd1      '***This is line 27****
>
>%>
>...
>
>I Will greatly appreciate your help!
>
>Cindy


  Return to Index