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