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. Data Commands OleDb

Data Commands OleDb

Scheduled Pinned Locked Moved C#
databasehelpannouncement
3 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.
  • T Offline
    T Offline
    thepolishguy
    wrote on last edited by
    #1

    I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.

    W K 2 Replies Last reply
    0
    • T thepolishguy

      I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.

      W Offline
      W Offline
      WillemM
      wrote on last edited by
      #2

      The syntax for the SQL command you will need is easy: UPDATE [table] SET [field]=[value],[field]=value,.. WHERE [filterexpression] Replace the [...] for the actual names and values. For the rest you need a simple piece of code like this:

      OleDbConnection connection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=mydb.mdb");
      OleDbCommand cmd = new OleDbCommand(query,connection);

      try {
      connection.Open();
      cmd.ExecuteNonQuery();
      }
      catch {
      //Whatever needs to be catched
      }
      finally {
      connection.Close();
      }

      Good luck. WM.
      What about weapons of mass-construction?

      1 Reply Last reply
      0
      • T thepolishguy

        I need to allow an administrator to change login passwords for my application but am having problems with the syntax for the UPDATE statement. Specifically, I want to use Data Commands rather than working through a data set to make the updates because I will only need to do two operations with the MS Access database-verifying the old password/user id combo and updating the password to a new one. It seems to me that the UPDATE statement requires paramaters, but I am unsure of the syntax. Any help would be appreciated. Thanks.

        K Offline
        K Offline
        kourvoisier
        wrote on last edited by
        #3

        If you were working thru a dataset you would not have to know any SQL statements after populating the dataset. Using the dataset is simple 1> create and fill the dataset with dataAdapter. 2> create new SQL command builder associated with dataAdapter 3> get new row from DataTable edit row(record) - (user/password) 4> simply update the database thru the adapter Besides from initially populating the dataset no SQL involved

        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