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. unable to update a table on a access database [modified]

unable to update a table on a access database [modified]

Scheduled Pinned Locked Moved C#
databasequestionannouncement
6 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.
  • M Offline
    M Offline
    mocasu
    wrote on last edited by
    #1

    hi all, Any ideas as to why the database is not being updated will be greatly appreciated! It is driving me mad...and I just can't see what i am doing wrong :confused: string dId = "Golden"; string dCharge = "150"; OleDbConnection connectDb = new OleDbConnection(db); connectDb.Open(); OleDbCommand update = new OleDbCommand("UPDATE ShippingCharges SET Charge = ? WHERE ShippingID = ?", connectDb); update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge; update.ExecuteNonQuery(); connectDb.Close(); -- modified at 12:18 Saturday 1st December, 2007

    L P 2 Replies Last reply
    0
    • M mocasu

      hi all, Any ideas as to why the database is not being updated will be greatly appreciated! It is driving me mad...and I just can't see what i am doing wrong :confused: string dId = "Golden"; string dCharge = "150"; OleDbConnection connectDb = new OleDbConnection(db); connectDb.Open(); OleDbCommand update = new OleDbCommand("UPDATE ShippingCharges SET Charge = ? WHERE ShippingID = ?", connectDb); update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge; update.ExecuteNonQuery(); connectDb.Close(); -- modified at 12:18 Saturday 1st December, 2007

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      mocasu wrote:

      update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge;

      shouldn't the update command be "Update ShippingCharges set Charge = @Charge where ShippingID = @ShippingID" if you call your updateParameters like that?

      M 1 Reply Last reply
      0
      • L Lost User

        mocasu wrote:

        update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge;

        shouldn't the update command be "Update ShippingCharges set Charge = @Charge where ShippingID = @ShippingID" if you call your updateParameters like that?

        M Offline
        M Offline
        mocasu
        wrote on last edited by
        #3

        Thanks...but either way the database is not being updated :(

        1 Reply Last reply
        0
        • M mocasu

          hi all, Any ideas as to why the database is not being updated will be greatly appreciated! It is driving me mad...and I just can't see what i am doing wrong :confused: string dId = "Golden"; string dCharge = "150"; OleDbConnection connectDb = new OleDbConnection(db); connectDb.Open(); OleDbCommand update = new OleDbCommand("UPDATE ShippingCharges SET Charge = ? WHERE ShippingID = ?", connectDb); update.Parameters.Add("@ShippingID", OleDbType.Char).Value = dId; update.Parameters.Add("@Charge", OleDbType.Integer).Value = dCharge; update.ExecuteNonQuery(); connectDb.Close(); -- modified at 12:18 Saturday 1st December, 2007

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          The parameters need to be added in the correct order. Even when named.

          M 1 Reply Last reply
          0
          • P PIEBALDconsult

            The parameters need to be added in the correct order. Even when named.

            M Offline
            M Offline
            mocasu
            wrote on last edited by
            #5

            Thanks a lot! :) As you said, I had just switched the add parameter code and ...voilA!

            P 1 Reply Last reply
            0
            • M mocasu

              Thanks a lot! :) As you said, I had just switched the add parameter code and ...voilA!

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #6

              Glad to be of service.

              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