Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sample Code of Network Handling
Message
From
02/04/2005 09:40:09
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
02/04/2005 07:00:15
Vinod Parwani
United Creations L.L.C.
Ad-Dulayl, Jordan
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01000962
Message ID:
01000976
Views:
22
>Can somebody pls provide some Sample Code of Handling dbf files in network i.e. code to open files, write files, delete records etc. in network.

First, you have to SET EXCLUSIVE OFF.

Next, you could use explicit record locking, but the modern and recommended approach is that you use buffering. Enable buffering on your tables - usually option 3 or 5 (optimistic record locking, or optimistic table locking). Sample commands, in a Form.Load():
set exclusive off && this is required for shared access in a network
set deleted on && nothing to do with network,
               && but usually you would want to include this
* Open tables
use Table1 in 0 order Field1
...
* Buffering:
CursorSetProp("Buffering", 5, "Table1")
...
Now, the user can do changes. To undo the changes:
* Form.OnCancel() && method added by programmer
TableRevert()
And to save changes, your code might be similar to the following:
* Form.OnSave() && method added by programmer
select Table1
if not TableUpdate() && if TableUpdate() failed
  local laError(1)
  aerror(laError)
  MessageBox("Can't save the record, message #"  trans(laError(1);
    + " Message: " + laError(2))
endif
Buffering is recommended, even if you don't use your program in a network.
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