If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > UPDATE code migrated from Access 2003 to SQL Server 2005 not working

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-07, 17:06
BillSinc BillSinc is offline
Registered User
 
Join Date: Jun 2005
Location: Denver, CO
Posts: 100
UPDATE code migrated from Access 2003 to SQL Server 2005 not working

I used to use the following code to update some table statistics when users login to a page. My old database was Access 2k3 and everything ran fine. Now I'm getting this error since I've migrated to SQL Server 2005.
Quote:
Microsoft SQL Native Client error '80040e14'

Incorrect syntax near '4'.

/TRWebSQL/Ownership_Reportreport.asp, line 401
The line it refers to is
Quote:
conn.Execute (strSQL)
Code:
<% 'Update Owner Visit
sSessionStatus = Session(ewSessionStatus)
sSessionUserName = Session(ewSessionUserName)
sRemoteAddress = Request.ServerVariables("REMOTE_ADDR")
sHTTP_UserAgent = Request.ServerVariables("HTTP_USER_AGENT")
dCurrentTime = Now()
If sSessionStatus = "login" Then
 If LEN(sRemoteAddress) > 0 AND LEN(sHTTP_UserAgent) > 0 Then
  strSQL = "UPDATE OWNERS " & _
           "SET Visits = Visits + 1, " & _ 
           "LastLogin = #" & dCurrentTime & "#, " & _
           "RemoteAddr = '" & sRemoteAddress & "', " & _
           "HttpUserAgent = '" & sHTTP_UserAgent & "' " & _
           "WHERE Access_Code = '" & sSessionUserName & "';"
  Set conn = Server.CreateObject("ADODB.Connection")
  conn.Open xDb_Conn_Str
  conn.Execute (strSQL)
  conn.Close
  Set conn = Nothing
  Set strSQL = Nothing    
 End If
End If
%>
__________________
BillS
Reply With Quote
  #2 (permalink)  
Old 02-13-07, 17:38
pbaldy pbaldy is offline
Registered User
 
Join Date: May 2005
Location: Nevada, USA
Posts: 2,475
Try replacing # with ' around the date. SQL Server doesn't require it.
__________________
Paul
Reply With Quote
  #3 (permalink)  
Old 02-13-07, 17:48
BillSinc BillSinc is offline
Registered User
 
Join Date: Jun 2005
Location: Denver, CO
Posts: 100
That did it. Many thanks!
__________________
BillS
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On