Microsoft KB Archive/155528

= HOWTO: Set Up an Offline View in Visual FoxPro 5.0 =

Article ID: 155528

Article Last Modified on 7/13/2004

-

APPLIES TO


 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q155528



SUMMARY
This article demonstrates the steps to create and use an offline view in Visual FoxPro.



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. In Visual FoxPro 6.0, the Testdata database can be found in the home+"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.</li>  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. </li> 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.</li> Issue a USE command to close Myview.</li>  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. </li> To make Myview a normal view or one that is considered ONLINE, you must use the DROPOFFLINEfunction, which deletes the three files that you created in the Myoffline directory. Any changes made to the view are reflected in the Customer table.</li></ol>

Keywords: kbhowto kbsqlprog kbdatabase KB155528

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.