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 windows application with ms access as database

update query in windows application with ms access as database

Scheduled Pinned Locked Moved C#
databasehelpannouncement
10 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
    J K Sharma
    wrote on last edited by
    #1

    Hi I have a problem in my windows application with ms access 2007 as database. The problem is that the update query to change password is giving error. the code i used is string qry1 = "update log_in set password='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'"; cmd = new OleDbCommand(qry1, con); cmd.ExecuteNonQuery(); MessageBox.Show("Password changes Sucessfully"); the error is "Syntax error in UPDATE statement." please answer. thanks in advance J.K.Sharma

    S C 2 Replies Last reply
    0
    • J J K Sharma

      Hi I have a problem in my windows application with ms access 2007 as database. The problem is that the update query to change password is giving error. the code i used is string qry1 = "update log_in set password='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'"; cmd = new OleDbCommand(qry1, con); cmd.ExecuteNonQuery(); MessageBox.Show("Password changes Sucessfully"); the error is "Syntax error in UPDATE statement." please answer. thanks in advance J.K.Sharma

      S Offline
      S Offline
      Sk93
      wrote on last edited by
      #2

      password is a reserved field name. Try changing your code to read:

      string qry1 = "update log_in set [password]='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'";

      R J 3 Replies Last reply
      0
      • J J K Sharma

        Hi I have a problem in my windows application with ms access 2007 as database. The problem is that the update query to change password is giving error. the code i used is string qry1 = "update log_in set password='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'"; cmd = new OleDbCommand(qry1, con); cmd.ExecuteNonQuery(); MessageBox.Show("Password changes Sucessfully"); the error is "Syntax error in UPDATE statement." please answer. thanks in advance J.K.Sharma

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

        If you let me use your application, I can erase your entire database. Try reading up on SQL injection attacks.

        Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

        S 1 Reply Last reply
        0
        • C Christian Graus

          If you let me use your application, I can erase your entire database. Try reading up on SQL injection attacks.

          Christian Graus Driven to the arms of OSX by Vista. "! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums. I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp

          S Offline
          S Offline
          Sk93
          wrote on last edited by
          #4

          unless he's protecting against it in "onChange" events of the text boxes perhaps.. or maybe on the lines above these? Assumption makes an.... ;)

          1 Reply Last reply
          0
          • S Sk93

            password is a reserved field name. Try changing your code to read:

            string qry1 = "update log_in set [password]='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'";

            R Offline
            R Offline
            Robert_Pan
            wrote on last edited by
            #5

            oledbparameter..... :zzz:

            1 Reply Last reply
            0
            • S Sk93

              password is a reserved field name. Try changing your code to read:

              string qry1 = "update log_in set [password]='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'";

              J Offline
              J Offline
              J K Sharma
              wrote on last edited by
              #6

              Thank you so much . It works as per you advice.

              1 Reply Last reply
              0
              • S Sk93

                password is a reserved field name. Try changing your code to read:

                string qry1 = "update log_in set [password]='" + txtnew.Text.Trim() + "' where userid='" + txtuser.Text + "'";

                J Offline
                J Offline
                J K Sharma
                wrote on last edited by
                #7

                when i create crystal report the database is at some location. but when i prepare setup of that windows application and deploy it on some other system then the path of database change and the crystal report does not load the correct database. Please help.. Thanks in advance.

                S 1 Reply Last reply
                0
                • J J K Sharma

                  when i create crystal report the database is at some location. but when i prepare setup of that windows application and deploy it on some other system then the path of database change and the crystal report does not load the correct database. Please help.. Thanks in advance.

                  S Offline
                  S Offline
                  Sk93
                  wrote on last edited by
                  #8

                  Consider using an application configuration file to store your database path / connectionstring. take a look at one of my other replies: http://www.codeproject.com/Messages/3093473/Re-XML-Call-me-stupid-LOL.aspx[^] Hope this helps :)

                  J 1 Reply Last reply
                  0
                  • S Sk93

                    Consider using an application configuration file to store your database path / connectionstring. take a look at one of my other replies: http://www.codeproject.com/Messages/3093473/Re-XML-Call-me-stupid-LOL.aspx[^] Hope this helps :)

                    J Offline
                    J Offline
                    J K Sharma
                    wrote on last edited by
                    #9

                    Thanks for your suggestion I have used app.config file to store connection string for rest of my application but i am unable to create cyrstal report using that string. Because when I create crystal report i need to use database field from field explorer which are present only when i establish connection at creation time of crystal report. Is there any other way to generate crystal report so that i can use app.config connection string for that.

                    S 1 Reply Last reply
                    0
                    • J J K Sharma

                      Thanks for your suggestion I have used app.config file to store connection string for rest of my application but i am unable to create cyrstal report using that string. Because when I create crystal report i need to use database field from field explorer which are present only when i establish connection at creation time of crystal report. Is there any other way to generate crystal report so that i can use app.config connection string for that.

                      S Offline
                      S Offline
                      Sk93
                      wrote on last edited by
                      #10

                      Try something like this:

                      foreach ([forgot object name] tbl in CRReport.Database.Tables)
                      {
                      tbl.SetLogOnInfo("",dbLocation,dbUser,dbPass)
                      tbl.Location = dbLocation
                      tbl.SetDataSource(dbLocation)
                      }

                      I've not got CR installed here, so can't double check the function and object names, but I believe that will redirect your database source for you :) The first parameter of "SetLogOnInfo" i think is a connection string, but I don't think you need this when reading from Access.. I've only ever used SQL Server, so I will say this is all just guess work :wtf: Anyways, hope it works for you! :cool:

                      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