Web Wiz - Solar Powered Eco Web Hosting

  New Posts New Posts RSS Feed - Incorrect syntax near '10'
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Incorrect syntax near '10'

 Post Reply Post Reply
Author
PrivateEye View Drop Down
Groupie
Groupie
Avatar

Joined: 21 March 2003
Location: United Kingdom
Status: Offline
Points: 168
Post Options Post Options   Thanks (0) Thanks(0)   Quote PrivateEye Quote  Post ReplyReply Direct Link To This Post Topic: Incorrect syntax near '10'
    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.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9791
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
PrivateEye View Drop Down
Groupie
Groupie
Avatar

Joined: 21 March 2003
Location: United Kingdom
Status: Offline
Points: 168
Post Options Post Options   Thanks (0) Thanks(0)   Quote PrivateEye Quote  Post ReplyReply Direct Link To This Post Posted: 24 July 2009 at 5:16pm
Yes it works, thank you for your help. Thumbs Up
The Judgement Day
Back to Top
milu View Drop Down
Newbie
Newbie


Joined: 09 October 2014
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote milu Quote  Post ReplyReply Direct Link To This Post 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");
   }
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.07
Copyright ©2001-2024 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Policy

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2024 Web Wiz Ltd. All rights reserved.