Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: SQL UPDATE Date Statement


Message #1 by "Tony Yates" <tony.yates@b...> on Thu, 20 Sep 2001 11:30:23
Hi



I have the following statement

sSQL = "UPDATE Page Set LastPers = '" & Session("Username") & "' ,LastTime 

#" & now() & "# WHERE Pageid = " & PAGE_ID



When I do a Response.write sSQL I get the following



UPDATE Page Set LastPers = 'Tony Yates ' ,LastTime = #20/09/01 11:29:51# 

WHERE Pageid = 1 





The error the page throws is





Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 



[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax 

near '11'. 



/DBEdit.asp, line 358 







LastTime field is set to datetime field, any ideas ??



Regards



Tony
Message #2 by irfan.syed@g... on Thu, 20 Sep 2001 19:00:17 +0800

Try



sSQL = "UPDATE Page Set LastPers = '" & Session("Username") & "'

,LastTime

'" & now() & "' WHERE Pageid = " & PAGE_ID



Or this if SQL datetime is same as Web server datetime



sSQL = "UPDATE Page Set LastPers = '" & Session("Username") & "'

,LastTime

= getDate() WHERE Pageid = " & PAGE_ID















"Tony Yates" <tony.yates@b...> on 09/20/2001 07:30:23

PM



Please respond to "ASP Databases" <asp_databases@p...>



To:   "ASP Databases" <asp_databases@p...>

cc:    (bcc: Irfan H Syed/DHS/DHBG)

Subject:  [asp_databases] SQL UPDATE Date Statement







Hi



I have the following statement

sSQL = "UPDATE Page Set LastPers = '" & Session("Username") & "'

,LastTime

#" & now() & "# WHERE Pageid = " & PAGE_ID



When I do a Response.write sSQL I get the following



UPDATE Page Set LastPers = 'Tony Yates ' ,LastTime = #20/09/01

11:29:51#

WHERE Pageid = 1





The error the page throws is





Microsoft OLE DB Provider for ODBC Drivers error '80040e14'



[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect

syntax

near '11'.



/DBEdit.asp, line 358







LastTime field is set to datetime field, any ideas ??



Regards



Tony



Message #3 by David Cameron <dcameron@i...> on Fri, 21 Sep 2001 11:25:28 +1000
One problem that is probably unrelated is that 20/09/01 is International

rather than US date format. You need to re-org your date before you insert

it in database. Another problem is that for SQL server you use ' to delimit

dates, rather than #. So your SQL string should become:



UPDATE Page Set LastPers = 'Tony Yates ' ,LastTime = '09/20/01 11:29:51'

WHERE Pageid = 1 



See where that gets you.



HTH



regards

David Cameron

nOw.b2b

dcameron@i...



-----Original Message-----

From: Tony Yates [mailto:tony.yates@b...]

Sent: Thursday, 20 September 2001 9:30 PM

To: ASP Databases

Subject: [asp_databases] SQL UPDATE Date Statement





Hi



I have the following statement

sSQL = "UPDATE Page Set LastPers = '" & Session("Username") & "' ,LastTime 

#" & now() & "# WHERE Pageid = " & PAGE_ID



When I do a Response.write sSQL I get the following



UPDATE Page Set LastPers = 'Tony Yates ' ,LastTime = #20/09/01 11:29:51# 

WHERE Pageid = 1 





The error the page throws is





Microsoft OLE DB Provider for ODBC Drivers error '80040e14' 



[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax 

near '11'. 



/DBEdit.asp, line 358 







LastTime field is set to datetime field, any ideas ??



Regards



Tony

  Return to Index