Re: how to get both old and new value for a changed text box
- From: "Izzy" <israel.richner@xxxxxxxxx>
- Date: 30 Sep 2006 15:49:22 -0700
I see, you need too accommodate both db's. Well....
The reason I would try to avoid comparing a controls value to a stored
old value is performance. You mentioned having hundreds of textbox's,
so it could turn into a lengthy process and sounds like it would be
maintenance intensive.
For now you will have to do whatever is timely necessary. Tag property
sounds fine. Only do sub classing if you really understand all that's
involved. Why make things more complicated then they need too be.
Moving forward...IMO, I would develop 2 versions of your app. 1 for
Access clients and another for SQL Server clients.
For the Sql Server clients I would add update, delete triggers to the
database tables and archive history that way. Or you could put this
logic in a Stored Procedure and make it a transaction. First adding to
history then update live data. This would also resolve any problems
with multiple people updating the same info at the same time.
For the Access version I would do as I suggested earlier, running an
insert too archive history then perform the update.
I'll bet since you're accommodating both SQL Server clients and
Access clients you're probably using OLEDB objects. This is another
reason to create 2 versions, this way your SQL Server clients will
benefit from SqlClient objects.
Let me know if you need any help.
Izzy
Kathy wrote:
Izzy,
The Access app I am porting from is in use at multiple businesses where
there is a mix of databases sizes; some use Access and some use SQL
Server as backend db (hence my need to accommodate both). My users
require saving unlimited field change history (w/ old & new values, who
made the change, date/time change made, field changed, etc), so the
history can get rather large. I would prefer to capture the changes at
the same time a record gets saved versus as each field changes for
synchronization purposes. Just curious, why do you recommend against
comparing against the cached (old) values? Also, does setting IsDirty
as you suggested prevent the automatic database update until you force
it? Another contributor suggested saving the old value in each
control's Tag property. That seems workable, too. Another contributor
suggested subclassing, but I would lose the control's visibility in the
designer which I really don't want to do.
Thanks for the help.
Kathy
Izzy wrote:
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
.
- Follow-Ups:
- References:
- Prev by Date: RE: Crystal Report or MS Word?
- Next by Date: Text File Manipulation
- 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
|