Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Update Statement

Update Statement

Scheduled Pinned Locked Moved Database
announcementhelp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jlawren7
    wrote on last edited by
    #1

    hi all this is killing me this statement appears to be correct but not sure strSQLUpdate = "UPDATE Software SET ((Name), (Description), (Version), (ProductKey), (Location)) = (['" & n & "'] , ['" & d & "'], ['" & v & "'], ['" & p & "'], ['" & l & "']) WHERE (Name) = {'" & n & "'}" i have tried with ( ) & with out { } as well VB6 app to ms access.mdb please help thank you :confused: Help is great only if you ask correctly :)

    C E L 3 Replies Last reply
    0
    • J jlawren7

      hi all this is killing me this statement appears to be correct but not sure strSQLUpdate = "UPDATE Software SET ((Name), (Description), (Version), (ProductKey), (Location)) = (['" & n & "'] , ['" & d & "'], ['" & v & "'], ['" & p & "'], ['" & l & "']) WHERE (Name) = {'" & n & "'}" i have tried with ( ) & with out { } as well VB6 app to ms access.mdb please help thank you :confused: Help is great only if you ask correctly :)

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Too many brackets for a start. What's going wrong ? What are you setting Name, Description, Version, etc. to. If nothing, take them out, if something, specify it. Christian I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer

      1 Reply Last reply
      0
      • J jlawren7

        hi all this is killing me this statement appears to be correct but not sure strSQLUpdate = "UPDATE Software SET ((Name), (Description), (Version), (ProductKey), (Location)) = (['" & n & "'] , ['" & d & "'], ['" & v & "'], ['" & p & "'], ['" & l & "']) WHERE (Name) = {'" & n & "'}" i have tried with ( ) & with out { } as well VB6 app to ms access.mdb please help thank you :confused: Help is great only if you ask correctly :)

        E Offline
        E Offline
        Edbert P
        wrote on last edited by
        #3

        Correct me if I'm wrong, but I think the syntax you used is only for INSERT (well, not quite, but similiar), not UPDATE. Try modifying your statement to:

        "UPDATE Software SET Name = '" & n & "', Description = '" & d &"', Version = '" & v & "'" WHERE Name = '" & n & "'

        Also, you don't need to set the name when it is used as the condition as the name would have the same value anyway. Hope it helps :) Edbert P. Sydney, Australia.

        J 1 Reply Last reply
        0
        • E Edbert P

          Correct me if I'm wrong, but I think the syntax you used is only for INSERT (well, not quite, but similiar), not UPDATE. Try modifying your statement to:

          "UPDATE Software SET Name = '" & n & "', Description = '" & d &"', Version = '" & v & "'" WHERE Name = '" & n & "'

          Also, you don't need to set the name when it is used as the condition as the name would have the same value anyway. Hope it helps :) Edbert P. Sydney, Australia.

          J Offline
          J Offline
          jlawren7
          wrote on last edited by
          #4

          that did it thank you the insert statement is like this INSERT INTO Software SET (Name, Description, Version, ProductKey, Location ) Values ( blah blah blah) :) Help is great only if you ask correctly :)

          1 Reply Last reply
          0
          • J jlawren7

            hi all this is killing me this statement appears to be correct but not sure strSQLUpdate = "UPDATE Software SET ((Name), (Description), (Version), (ProductKey), (Location)) = (['" & n & "'] , ['" & d & "'], ['" & v & "'], ['" & p & "'], ['" & l & "']) WHERE (Name) = {'" & n & "'}" i have tried with ( ) & with out { } as well VB6 app to ms access.mdb please help thank you :confused: Help is great only if you ask correctly :)

            L Offline
            L Offline
            Luis Alonso Ramos
            wrote on last edited by
            #5

            I recommend using parametized queries. See the documentation for the Parameters property of the OleDbCommand/SqlDbCommand classes. With parametized queries you avoid problems like invalid characters (a quote for example) or someone trying to hijaack your database by inserting SQL statements. EDIT: See this[^] post. -- LuisR


            Luis Alonso Ramos Intelectix - Chihuahua, Mexico Not much here: My CP Blog!

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups