How to update my access to current date??

Discussion in 'ASP General' started by D, Oct 2, 2004.

  1. D

    D Guest

    Hi, got a problem here. I try using the following sql statement..

    strSQL = "UPDATE Messages(TABLE) SET Date=now() where MessageID=25"

    The error given to me:
    Syntax error in UPDATE statement.

    I'm doing an update of the date already stored in my Access. How do i
    resolve this problem?? Thanks

    cheers

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    D, Oct 2, 2004
    #1
    1. Advertising

  2. D

    John Guest

    If Date is a field, name it myDate instead of Date (reserved word)

    <D> schreef in bericht news:...
    > Hi, got a problem here. I try using the following sql statement..
    >
    > strSQL = "UPDATE Messages(TABLE) SET Date=now() where MessageID=25"
    >
    > The error given to me:
    > Syntax error in UPDATE statement.
    >
    > I'm doing an update of the date already stored in my Access. How do i
    > resolve this problem?? Thanks
    >
    > cheers
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    John, Oct 2, 2004
    #2
    1. Advertising

  3. D wrote:
    > Hi, got a problem here. I try using the following sql statement..
    >
    > strSQL = "UPDATE Messages(TABLE) SET Date=now() where MessageID=25"
    >
    > The error given to me:
    > Syntax error in UPDATE statement.
    >
    > I'm doing an update of the date already stored in my Access. How do i
    > resolve this problem?? Thanks
    >


    John is correct. You used a reserved keyword for a column name (Date). This
    should be avoided, but if you cannot change the column name, you can work
    around it by surrounding the column name with brackets [] when you use it in
    your sql statements executed via ADO:

    ... SET [Date]=now() ...

    For more words to avoid in your databases, see here:
    http://www.aspfaq.com/show.asp?id=2080

    Bob Barrows
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Oct 2, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James P.
    Replies:
    7
    Views:
    12,462
    phamtasmic
    Jul 13, 2004
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,228
    Michael Borgwardt
    May 30, 2004
  3. moonhk
    Replies:
    5
    Views:
    528
    moonhk
    Oct 11, 2006
  4. Michael Haas

    compare date field to current date

    Michael Haas, Feb 15, 2004, in forum: ASP General
    Replies:
    4
    Views:
    273
    Mike Haas
    Feb 15, 2004
  5. Replies:
    3
    Views:
    355
Loading...

Share This Page