|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Prevent rowstate change for one columnHi!
I have an DataTable with one extra column that I've added manually, and is not in the database. I use this col for various calculations, and it should never be saved to the db. That works fine, except for one thing: when I change the value in a row for that col, the RowState becomes Modified. That's natural I guess, but it's unneccecary because it sends unmodified rows to the db. Is there a way of marking a col as "computed" or other technique to avoid changing the rowstate when changing that columns value? regards Carl datarow.AcceptChanges()
Show quote "Carl" <ask4it> wrote in message news:OlsQ1wWWGHA.3376@TK2MSFTNGP02.phx.gbl... > Hi! > > I have an DataTable with one extra column that I've added manually, and is > not in the database. I use this col for various calculations, and it > should never be saved to the db. That works fine, except for one thing: > when I change the value in a row for that col, the RowState becomes > Modified. That's natural I guess, but it's unneccecary because it sends > unmodified rows to the db. Is there a way of marking a col as "computed" > or other technique to avoid changing the rowstate when changing that > columns value? > > regards > > Carl > That is not an option in my case, since there might (will) be other changes
to the row, and I do not wish to accept those changes. Show quote "Jim Hughes" <NOSPAMJ3033@Hotmail.com> wrote in message news:e$zV9iXWGHA.1352@TK2MSFTNGP05.phx.gbl... > datarow.AcceptChanges() > > "Carl" <ask4it> wrote in message > news:OlsQ1wWWGHA.3376@TK2MSFTNGP02.phx.gbl... >> Hi! >> >> I have an DataTable with one extra column that I've added manually, and >> is not in the database. I use this col for various calculations, and it >> should never be saved to the db. That works fine, except for one thing: >> when I change the value in a row for that col, the RowState becomes >> Modified. That's natural I guess, but it's unneccecary because it sends >> unmodified rows to the db. Is there a way of marking a col as "computed" >> or other technique to avoid changing the rowstate when changing that >> columns value? >> >> regards >> >> Carl >> > > Then do a test to see If Not dataRow.HasChanges() before accepting them.
Show quote "Carl" <ask4it> wrote in message news:ehMCmCYWGHA.4452@TK2MSFTNGP04.phx.gbl... > That is not an option in my case, since there might (will) be other > changes to the row, and I do not wish to accept those changes. > > "Jim Hughes" <NOSPAMJ3033@Hotmail.com> wrote in message > news:e$zV9iXWGHA.1352@TK2MSFTNGP05.phx.gbl... >> datarow.AcceptChanges() >> >> "Carl" <ask4it> wrote in message >> news:OlsQ1wWWGHA.3376@TK2MSFTNGP02.phx.gbl... >>> Hi! >>> >>> I have an DataTable with one extra column that I've added manually, and >>> is not in the database. I use this col for various calculations, and it >>> should never be saved to the db. That works fine, except for one thing: >>> when I change the value in a row for that col, the RowState becomes >>> Modified. That's natural I guess, but it's unneccecary because it sends >>> unmodified rows to the db. Is there a way of marking a col as "computed" >>> or other technique to avoid changing the rowstate when changing that >>> columns value? >>> >>> regards >>> >>> Carl >>> >> >> > > |
|||||||||||||||||||||||