Manipulating Offline Data

There are times when you might want to display, collect, or modify data independent of the host database. By using the offline view features in Visual FoxPro, you can use views to connect to a host database and create a subset of data for use offline. Then, working offline, you can use the view directly or through an application you create. When you are done, you can upload the changes stored in the view back to the host database.

Some scenarios where offline views are useful include:

  • A data warehousing situation, where large databases are maintained centrally on MIS servers. If you are only interested in data pertaining to, for example, the Marketing department, you can construct a view including only the data that is relevant to you. You can then take the data offline, allow multiple users in the Marketing department to update the data, and then commit the changed data to the source database.

  • A geographically remote location which requires that you take a subset of data with you on a laptop, modify the data independently of the host database, then update the host database with the changed data at a later time.

  • Time-sensitive data. For example, you might want to update data reflecting employee pay raises before the new pay rates actually take effect.

Working with offline views

FoxPro DataView

Using the offline view, you can display and update data much as you do online with the same forms, reports, or applications.

To create and use view data offline, you can use the following language features:

  • The CREATEOFFLINE( ) function.

  • The USE SQLViewName command with the ADMIN and ONLINE clauses.

    For example, the following code opens the Showproducts view:

    USE Showproducts
    
  • The TABLEUPDATE function.

  • The DROPOFFLINE( ) function.

If you are not getting the subset of data that you expected, check the optimization settings for the remote view. If you set the MaxRecords property using the DBSETPROP( ) function, only that many records appear in your views offline. However, if you include a Memo field in the field list of your view, it is automatically included in the result set even if FetchMemo is set to false (.F.).

If you plan to use the offline view on a machine other than the one on which you created the offline view, you must prepare the offline destination by creating a copy of the host database file (.dbc); making sure the ODBC data source used by the view exists on the destination machine; and analyzing your data requirements to determine the contents of the view you need.

Note

Use the ODBC Administrator program to install data sources on a machine. You can access the ODBC Administrator program from either the Visual FoxPro program group or from the Control Panel.

After you create the view for your offline data, you can use it as you would any view in your application: you can add, change, and delete records. Multiple users can access the offline view concurrently using the same database in shared mode. If you decide you do not want to keep any of the changes, you can revert the information to reflect the original information.

Administering Data Offline

In some cases — especially in a multiple-user environment where numerous people modify data — you might want to examine changes made to the offline view before committing the changes to the source database. With the USE command and the ADMIN clause, you can see all changes that have been committed to a view since it was taken offline. You can then selectively revert changes that have been made without being connected to the data source. For example, the following code opens the view Showproducts in administrator mode:

USE Showproducts ADMIN

See Also

Tasks

How to: Create Offline Views

Concepts

Updating Data Using Transactions

Other Resources

Working with Views (Visual FoxPro)