>What's the difference and/or similarities between FLUSH and TABLEUPDATES? Can it be used together?
>
>Thanks,
>
>Sonny
You should use both, IMO. Buffering allows you to save changes or undo changes done by the user (or programmatically). Visual FoxPro keeps track of changes, in internal buffers. You save changes with TableUpdate(), and undo changes with TableRevert().
The operating system keeps its own buffers; these should be emptied (copied to hard disk) with the FLUSH command. If you use buffering, you should do this after a TableUpdate(), if it is successful.
Sample code, for the Click() event in a button labelled "Save", or (better) a form method invoked by this button:
if not TableUpdate()
local laError(1)
aerror(laError)
MessageBox("Can't save changes; error #" + laError(1);
+ " - " + laError(2))
endif
If TableUpdate() returns .T., the information was saved successfully. TableUpdate() can fail for several reasons, mainly, if some rule is violated. The most common violations are 1) a trigger created automatically by referential integrity, and 2) some other user changed the same record while the user was editing.
HTH,
Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)