Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Usage of Flush and Tableupdates?
Message
From
22/09/2006 09:20:27
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
22/09/2006 02:35:05
Sonny Tabano
Trams Printwork, Inc.
Mabalacat, Philippines
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01156290
Message ID:
01156383
Views:
19
>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)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform