Print Page | Close Window

Incorrect syntax near '10'

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=27610
Printed Date: 28 March 2026 at 1:39pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Incorrect syntax near '10'
Posted By: PrivateEye
Subject: Incorrect syntax near '10'
Date Posted: 23 July 2009 at 5:19pm
I am trying to insert current date and time in SQL server 2008 using ASP.net 3.5 and getting this error.
 
Incorrect syntax near '10'. My code is as under :-
 
Table Name: Region
Column Name: Modification_date
 

Dim cmdInsert As SqlCommand

Dim strSQL As String

strSQL = "UPDATE dbo.Region SET Modification_date = " & Now() & " WHERE RegionID = " & intRegionID

cmdInsert = New SqlCommand(strSQL, cnConnection)

cmdInsert.ExecuteNonQuery()

When I run the script, it is giving this error in cmdInsert.ExecuteNonQuery(). I tried to add # signs alongwith Now() like this
 
strSQL = "UPDATE dbo.Region SET Modification_date = #" & Now() & "# WHERE RegionID = " & intRegionID
 
But same error. Can anyone please help me.



Replies:
Posted By: WebWiz-Bruce
Date Posted: 24 July 2009 at 9:10am
Surrounding dates with a hash # is used for Access databases, with SQL Server use a single quote ' either side of the date eg:-

strSQL = "UPDATE dbo.Region SET Modification_date = '" & Now() & "' WHERE RegionID = " & intRegionID


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: PrivateEye
Date Posted: 24 July 2009 at 5:16pm
Yes it works, thank you for your help. Thumbs Up

-------------
The Judgement Day


Posted By: milu
Date Posted: 09 October 2014 at 2:12pm
How do you get the forum to keep the code highlight syntax when you paste in the code?
 
When i paste code in forum it lose the color coding and so on..
 
 
 
example:
#include<stdio.h>
 
int main()
{
   int n, i = 3, count, c;
 
   printf("Enter the number of prime numbers required\n");
   scanf("%d",&n);
 
   if ( n >= 1 )
   {
      printf("First %d prime numbers are :\n",n);
      printf("2\n");
   }



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net