Re: how to get both old and new value for a changed text box
- From: "Izzy" <israel.richner@xxxxxxxxx>
- Date: 30 Sep 2006 07:17:26 -0700
Kathy,
I had a nice long respone written for you....then my stupid computer
over heated and turned off.
Anyway...here's an idea:
If this data is being stored in Access, you could insert the old data
into the history table before you run your update. This will create a
little extra duty for your database server but a very common task for
audit tracking.
I would try to avoid comparing each textbox's value with a cached
initial value too determine if changes have been made. I usually just
define a boolean property called "IsDirty" and on validating of the
textbox controls set this property to true. You can then use that to
determine if an update and insert needs to take place.
If IsDirty Then
MoveToHistory(PrimaryKey)
UpdateTable(PrimaryKey)
IsDirty = False
Else
'No Changes Detected
End If
Just curious...How big is this Access database? AND how much history do
you need too store?
Izzy
Kathy wrote:
Hi Izzy,
I was just noticing if I leave a textbox, I can get to the
bindingsource's current datarowview which has the old value as you
indicated; that is, unless I do an EndEdit. However, if I leave the
parent of the textbox (e.g. leave the tab page the textbox resides on),
then apparently an EndEdit is automatic because the current
datarowview has the new value at that point.
I should probably manipulate the data directly which I do for non-UI
related tasks. Is there a significant difference in performance
between the 2 data manipulation methods?
Thanks.
Kathy
Izzy wrote:
Something else you might think about Kathy,
I usually read data directly into controls like textbox's using a data
reader. I did work on a project in my early days of .NET where we used
a Currency Manager and the controls were bound too the DataTable. In
this set up, before the Table.AcceptChanges() method is called the
table actually contains the original value and proposed value.
This way there would be no reason to check every control individually.
Do some reading in the BOL about DataTables and Currency Managers.
Additionally, you mentioned Sql Server, if this is the database your
using then I would put an Update Trigger on the table and when it
fires, insert the old record into an identical table.
On another note.....
Sorry about the sarcastic feedback you got, in our line of work their
seems to be a lot if idiots with god syndrome.
Izzy
.
- Follow-Ups:
- References:
- Prev by Date: Re: Securing my app with serial number
- Next by Date: Re: Think BEFORE you post.
- Previous by thread: Re: how to get both old and new value for a changed text box
- Next by thread: Re: how to get both old and new value for a changed text box
- Index(es):
Relevant Pages
|