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. Can't update table with expression field

Can't update table with expression field

Scheduled Pinned Locked Moved Database
designhelpannouncement
5 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
    Muammar
    wrote on last edited by
    #1

    SELECT ID, PRODUCT, PRICE, QTY, PRICE*QTY AS TOTAL FROM PRODUCTS I added the expression PRICE*QTY in the adapter select statement in the design time, now the values can't be updated when running the bound datagridview ie. loads but doesn't save changes. Please help.

    L M 2 Replies Last reply
    0
    • M Muammar

      SELECT ID, PRODUCT, PRICE, QTY, PRICE*QTY AS TOTAL FROM PRODUCTS I added the expression PRICE*QTY in the adapter select statement in the design time, now the values can't be updated when running the bound datagridview ie. loads but doesn't save changes. Please help.

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Not really a surprise: if you were to edit TOTAL (so it no longer equals PRICE*QTY), what should the database do??? I would start by making the TOTAL column read-only. Not sure that will be sufficient though. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      M 1 Reply Last reply
      0
      • M Muammar

        SELECT ID, PRODUCT, PRICE, QTY, PRICE*QTY AS TOTAL FROM PRODUCTS I added the expression PRICE*QTY in the adapter select statement in the design time, now the values can't be updated when running the bound datagridview ie. loads but doesn't save changes. Please help.

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Mate you need to look into a proper data access layer. You are using the built in adaptors and running up against their limitations. The reason I didn't follow up on the last problem was I don't know, I and all good developers use and understand the DAL. It's a learning thing but you obviously need to move to the next stage and get to know how your data is delivered, get to know stored procedures as well.

        Never underestimate the power of human stupidity RAH

        M 1 Reply Last reply
        0
        • L Luc Pattyn

          Not really a surprise: if you were to edit TOTAL (so it no longer equals PRICE*QTY), what should the database do??? I would start by making the TOTAL column read-only. Not sure that will be sufficient though. :)

          Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

          M Offline
          M Offline
          Muammar
          wrote on last edited by
          #4

          Thanks Luc, Of course I'm not editing the totals and they're set to read only, I just need the user to see it as the values are entered.. The funny thing is that, I've done it before and I just don't seem to remember how.. Thanks mate!

          1 Reply Last reply
          0
          • M Mycroft Holmes

            Mate you need to look into a proper data access layer. You are using the built in adaptors and running up against their limitations. The reason I didn't follow up on the last problem was I don't know, I and all good developers use and understand the DAL. It's a learning thing but you obviously need to move to the next stage and get to know how your data is delivered, get to know stored procedures as well.

            Never underestimate the power of human stupidity RAH

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

            Thanks Holmes, you're absolutely right, actually, I never used the designer when it comes to database programming and this's exactly why I'm asking now.. Guess I'll just have to forget about the designer.. I thought if it will make my life easier, why not to go for it.

            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