The information in this article applies to:
- Microsoft Visual FoxPro for Windows, version 5.0
SUMMARY
This article shows you the steps to create and use an offline view within
Visual FoxPro 5.0.
MORE INFORMATION
With the following steps, you can create a sample offline view using the
data from the Testdata database from the Samples\Data directory.
- Create a new directory called Myoffline, and make it the default
directory.
- Open the Testdata database in the C:\VFP\Samples\Data directory.
- Create a new .dbc file called Mydbc, and modify this database.
- Within Mydbc, create a new Local View from the Customer table and
include all fields as output. Check Send SQL Updates, and mark the
Cust_ID field as modifiable in the Update criteria tab.
NOTE: An offline view does not have to be from a local view; it can
also come from a remote view, adding more power to this feature.
- Close and save the view, and name it Myview.
- From the Command window issue the command:
? CREATEOFFLINE("MYVIEW")
If the command executes successfully, it returns a .T., and now if you
look at the files in the Myoffline directory, you should see three
extra files with the following names:
Myview.dbf
Myview.tbf
Myview.tdx
The view Myview is now considered offline. You can take the contents of
the MYOFFLINE folder anywhere and make changes to the data in Myview
view.
- Issue a CLOSE All command from the Command window to close all the
files.
- Next issue the following commands from the Command window:
SET MULTILOCKS ON
OPEN DATABASE MYDBC
USE MYVIEW
BROWSE
Multilocks must be set on in order to use the view. You can look at the
records and modify them.
- Modify or append a couple of records. Because the view is offline, only
the records in Myview.dbf are actually changed. Nothing is being
changed in the Customer table.
- Issue a USE command to close Myview.
- To update the Customer table, issue the following commands:
OPEN DATABASE c:\vfp\samples\data\testdata
USE Customer
? CURSORSETPROP("Buffering",5)
USE Myview ONLINE EXCLUSIVE IN 0
SELECT Myview
? TABLEUPDATE(.T.)
If you BROWSE the Customer table, you should see your changes. You must
open the view with the ONLINE clause, and it must be exclusive in order
to update. Also the table and database the view is representing, in
this case Customer, must be open.
- To make Myview a normal view or one that is considered ONLINE, you must
use the DROPOFFLINE()function, which deletes the three files that you
created in the Myoffline directory. Any changes made to the view are
reflected in the Customer table.
|