Re: how to get both old and new value for a changed text box



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

.



Relevant Pages

  • Data Controls Suck: No Vertical Layout?
    ... it really seems to be non-existent to find controls in the framework or documentation or hacks that will help me get an editable grid or editable datalist in vertical format. ... I want and need two columns, the left is a LinkButton with text property that has the name of the database field and the right the TextBox that contains the data in from the database that CRUD can then function with. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Known issue with copying Controls from 03 to 2007
    ... What I did was take controls from an 03 database and created a new database ... and tried running the after_update event on textbox 1, ... rather than highlight the data entered in textbox 1 ...
    (microsoft.public.access.forms)
  • Re: Trouble With Access Form Controls
    ... > also exactly the name of the field that the textbox is bound to. ... > controls, ... > Chris Durant via AccessMonster.com wrote: ... >> I have a database that is used by a call centre to mark the quality of calls ...
    (microsoft.public.access.formscoding)
  • Re: Trouble With Access Form Controls
    ... Can you confirm that MSalesDev57 is exactly the name of the textbox, and also exactly the name of the field that the textbox is bound to. ... If all this checks out, it is possible there is some corruption introduced by the copy/paste of controls, I have seen this happen. ... You could try deleting the troublesome textboxes, save the form, compact/repair the database, and then manually add the textboxes back again. ... Private Sub TechN34_AfterUpdate ...
    (microsoft.public.access.formscoding)
  • Re: The Zen nature of a Delphi database application
    ... results directly to UI controls, then write data from the controls to ... then write data back from the modified objects to the DB for storage? ... I load the whole contents of the database into my business objects, ... I have dreamt of the perfect OO database application framework ...
    (comp.lang.pascal.delphi.misc)