locked
Error with Update Statement RRS feed

  • Question

  • I'm getting an error with the below Update statement.  I am trying to update data in a Access DB.  When running from my application, this statement is giving me the 'Syntax error in UPDATE statement' exception, but when I go into debugger and copy the Update statement and create a query in the DB and paste it into the SQL Query and hit run, it works.  Any help would be appreciated.  All the fields are Text fields in the DB as well.

     UPDATE MovieDetails SET Director = 'Tim Burton', ReleaseDate = '23 June 1989 (USA)', Genre = 'Action', Cast = 'Jack Nicholson, Kim Basinger, Robert Wuhl, Pat Hingle, Billy Dee Williams, Michael Gough, Jack Palance, Matt Wright', Length = '126 min', Rated = 'PG-13' WHERE DetailsID = '202ee69f-6195-4f18-890d-270de571789b'
    Thursday, January 15, 2009 5:48 PM

Answers

  • I have figured out my problem.  For some reason I had to place brackets around the word Cast in my VB code.  The Update statement now looks like:

    UPDATE MovieDetails SET Director = 'Tim Burton', ReleaseDate = '23 June 1989 (USA)', Genre = 'Action', [Cast] = 'Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl, Pat Hingle, Billy Dee Williams, Michael Gough, Jack Palance', Length = '126 min', Rated = 'PG-13' WHERE (DetailsID = '6cd0bf88-bcef-4c50-a083-6c8261c94149')

    • Marked as answer by Wright2020 Thursday, January 15, 2009 8:12 PM
    Thursday, January 15, 2009 8:11 PM

All replies

  • Well, I have figured out that the problem is in the Cast portion of the Update statement.  There is something in VB that doesn't like the extra commas in the Cast field I think.  Any help would be appreciated.
    Thursday, January 15, 2009 7:57 PM
  • I have figured out my problem.  For some reason I had to place brackets around the word Cast in my VB code.  The Update statement now looks like:

    UPDATE MovieDetails SET Director = 'Tim Burton', ReleaseDate = '23 June 1989 (USA)', Genre = 'Action', [Cast] = 'Michael Keaton, Jack Nicholson, Kim Basinger, Robert Wuhl, Pat Hingle, Billy Dee Williams, Michael Gough, Jack Palance', Length = '126 min', Rated = 'PG-13' WHERE (DetailsID = '6cd0bf88-bcef-4c50-a083-6c8261c94149')

    • Marked as answer by Wright2020 Thursday, January 15, 2009 8:12 PM
    Thursday, January 15, 2009 8:11 PM