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. General Programming
  3. C#
  4. Update Query in MS Access

Update Query in MS Access

Scheduled Pinned Locked Moved C#
databasehelptutorialquestionannouncement
11 Posts 3 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.
  • D DKalepu

    Hi all, how to write update Query in MS Access?? in sql, we write like this "update tablename set field = '"+ +"' where field= '"+ +"'";" but its giving an error whenever i write the same query in access...... so, could any one help me how to write "update Query in ms access plz/// Thanks in Advance.! :)

    R Offline
    R Offline
    Robert Rohde
    wrote on last edited by
    #2

    Hi, your syntax is principally correct. What error are you getting? Robert

    D 1 Reply Last reply
    0
    • D DKalepu

      Hi all, how to write update Query in MS Access?? in sql, we write like this "update tablename set field = '"+ +"' where field= '"+ +"'";" but its giving an error whenever i write the same query in access...... so, could any one help me how to write "update Query in ms access plz/// Thanks in Advance.! :)

      M Offline
      M Offline
      Muhammad Gouda
      wrote on last edited by
      #3

      "update tablename set field = '"+ +"' where field= '"+ +"'";" If the above is exactly your code. It is a matter of c# syntax Actually you have redundant " The correction is "update tablename set field = '"+ +"' where field= '"+ +"';" Also, you can truncate the smicolon of the query "update tablename set field = '"+ +"' where field= '"+ +"'" I hope this helps :laugh::laugh:

      Mohamed Gouda Egypt

      D 1 Reply Last reply
      0
      • R Robert Rohde

        Hi, your syntax is principally correct. What error are you getting? Robert

        D Offline
        D Offline
        DKalepu
        wrote on last edited by
        #4

        Hi, its saying "Syntax error in UPDATE statement" :confused:

        1 Reply Last reply
        0
        • M Muhammad Gouda

          "update tablename set field = '"+ +"' where field= '"+ +"'";" If the above is exactly your code. It is a matter of c# syntax Actually you have redundant " The correction is "update tablename set field = '"+ +"' where field= '"+ +"';" Also, you can truncate the smicolon of the query "update tablename set field = '"+ +"' where field= '"+ +"'" I hope this helps :laugh::laugh:

          Mohamed Gouda Egypt

          D Offline
          D Offline
          DKalepu
          wrote on last edited by
          #5

          Hi, thanks for the reply... i have tried these two cases: its giving error like " ; expected " actually this is my query statements:: string strQuery = "update UserInfo set Password = '"+ txtNewPwd.Text +"' where Password = '"+ txtOldPwd.Text +"'"; any other solution plz...

          M R 3 Replies Last reply
          0
          • D DKalepu

            Hi, thanks for the reply... i have tried these two cases: its giving error like " ; expected " actually this is my query statements:: string strQuery = "update UserInfo set Password = '"+ txtNewPwd.Text +"' where Password = '"+ txtOldPwd.Text +"'"; any other solution plz...

            M Offline
            M Offline
            Muhammad Gouda
            wrote on last edited by
            #6

            Make sure you use the correct spacing However, set a break point at that statement and debug to wathc the string

            Mohamed Gouda Egypt

            D 1 Reply Last reply
            0
            • M Muhammad Gouda

              Make sure you use the correct spacing However, set a break point at that statement and debug to wathc the string

              Mohamed Gouda Egypt

              D Offline
              D Offline
              DKalepu
              wrote on last edited by
              #7

              well, i did debug using break point.. Actually, it is executing the code step by step but at the end of the debugging a message box displayed "syntax error in UPDATE statement" ..

              1 Reply Last reply
              0
              • D DKalepu

                Hi, thanks for the reply... i have tried these two cases: its giving error like " ; expected " actually this is my query statements:: string strQuery = "update UserInfo set Password = '"+ txtNewPwd.Text +"' where Password = '"+ txtOldPwd.Text +"'"; any other solution plz...

                M Offline
                M Offline
                Muhammad Gouda
                wrote on last edited by
                #8

                string strQuery = "update UserInfo set Password = '"+ txtNewPwd.Text +"' where Password = '"+ txtOldPwd.Text +"'"; In the aove string you need to take space before WHERE Note that 'where is COMPLETELY different from ' where This missed space makes the error

                Mohamed Gouda Egypt

                D 1 Reply Last reply
                0
                • M Muhammad Gouda

                  string strQuery = "update UserInfo set Password = '"+ txtNewPwd.Text +"' where Password = '"+ txtOldPwd.Text +"'"; In the aove string you need to take space before WHERE Note that 'where is COMPLETELY different from ' where This missed space makes the error

                  Mohamed Gouda Egypt

                  D Offline
                  D Offline
                  DKalepu
                  wrote on last edited by
                  #9

                  there is space b/w ' & WHERE........ :confused: :((

                  1 Reply Last reply
                  0
                  • D DKalepu

                    Hi, thanks for the reply... i have tried these two cases: its giving error like " ; expected " actually this is my query statements:: string strQuery = "update UserInfo set Password = '"+ txtNewPwd.Text +"' where Password = '"+ txtOldPwd.Text +"'"; any other solution plz...

                    R Offline
                    R Offline
                    Robert Rohde
                    wrote on last edited by
                    #10

                    It might be that Password is a keyword in Access try: string strQuery = "update UserInfo set \"Password\" = '"+ txtNewPwd.Text +"' where \"Password\" = '"+ txtOldPwd.Text +"'"; Robert

                    D 1 Reply Last reply
                    0
                    • R Robert Rohde

                      It might be that Password is a keyword in Access try: string strQuery = "update UserInfo set \"Password\" = '"+ txtNewPwd.Text +"' where \"Password\" = '"+ txtOldPwd.Text +"'"; Robert

                      D Offline
                      D Offline
                      DKalepu
                      wrote on last edited by
                      #11

                      Hi, thanks for the help! yes, Password is a keyword in Access. I have changed it to "pwd" & it worked very well....... Thanks!

                      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