Microsoft Knowledge Base Email Alertz

(192857) - The introduction of Offline views in Visual FoxPro 5.0 enabled users to work with selected data sets while disconnected from the server. Use of indexes and functions that take advantage of Rushmore Optimization provide a highly efficient method of...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 192857 - Last Review: July 13, 2004 - Revision: 1.2

How To Use Index Files with Offline Views

This article was previously published under Q192857

SUMMARY

The introduction of Offline views in Visual FoxPro 5.0 enabled users to work with selected data sets while disconnected from the server. Use of indexes and functions that take advantage of Rushmore Optimization provide a highly efficient method of searching Offline view data sets.

This article explains how to create and use indexes with Offline views.

MORE INFORMATION

Creation of an Offline view creates a table structure and properties that match the structure and properties of the source view. Issuing an index command with an Offline view creates an index file for the Offline view. The Table and Index(es) remain in the directory in which the Offline view was created until a DROPOFFLINE() command is issued or the Offline view is USEd ONLINE or in ADMIN mode. When the Offline view is taken back online, the table and index files are deleted from the disk.

Create a program file named OFFINDEX.PRG, using the following code:
   SET SAFETY OFF
   SET MULTILOCKS ON
   * Create a database
   CREATE DATABASE MYOLV
   * Declare API function to create ODBC DSN
   DECLARE INTEGER SQLConfigDataSource IN odbccp32.DLL ;
      INTEGER, INTEGER, STRING, STRING
   IF VAL(SUBSTR(VERSION(),15,2))=6
      lcDir=HOME(2)+"data\"
   ELSE
      lcDir=HOME()+"SAMPLES\DATA\"
   ENDIF
   * Information to setup ODBC DSN
   lcSetUp="DSN=MyOffLine"+CHR(0)+;
      "Description=VFP Offline View Demo"+CHR(0)+;
      "SourceDB="+lcDir+"testdata.dbc"+CHR(0)+;
      "SourceType=DBC"
   * Call API function to create a DSN
   =SQLConfigDataSource(0,1,"Microsoft Visual FoxPro Driver",lcSetUp)
   CLEAR DLLS
   * Create a connection
   CREATE CONNECTION MyOLV DATASOURCE "myoffline"
   * Create a view to take offline
   CREATE SQL VIEW test REMOTE CONNECT MyOLV ;
      AS SELECT cust_id, company, city ;
      FROM customer ;
      ORDER BY customer.cust_id
   USE test
   * Take the view offline
   * Creates file named 'TEST.DBF'
   =CREATEOFFLINE('test')
   * Close all and open the Table for OffLine view
   CLOSE ALL
   USE test.dbf
   * Create structural indexes on the Offline view
   INDEX ON cust_id TAG cust_id OF ALIAS()
   INDEX ON city TAG city OF ALIAS()
   * Set the order to customer id
   SET ORDER TO TAG cust_id
   LOCATE
   BROWSE TITLE "ORDERED BY CUSTOMER ID"
   * Set the order to city
   SET ORDER TO TAG city
   BROWSE TITLE "ORDERED BY CITY"
   * Create an IDX index
   INDEX ON city+company TO cocity
   BROWSE TITLE "ORDERED BY City and Company Using IDX FILE"
   * Revert any changes and take the view back online
   CLOSE ALL
   OPEN DATABASE MyOLV
   =DROPOFFLINE('test')
   * Indexes and working table destroyed with dropoffline command.
   * Close the view
   CLOSE ALL
   RETURN
				
Note that the table order changes when the order is changed. Also note that the table and all associated files are deleted when the offline view is taken back online.

REFERENCES

For additional information, please see the following articles in the Microsoft Knowledge Base:
165234  (http://kbalertz.com/Feedback.aspx?kbNumber=165234/EN-US/ ) PRB: CREATEOFFLINE Opens Parent Table Exclusively

156552  (http://kbalertz.com/Feedback.aspx?kbNumber=156552/EN-US/ ) How To Use Offline Views in Visual FoxPro

156013  (http://kbalertz.com/Feedback.aspx?kbNumber=156013/EN-US/ ) INFO: Possible Uses for Offline Views in Visual FoxPro

156011  (http://kbalertz.com/Feedback.aspx?kbNumber=156011/EN-US/ ) INFO: Use of the ADMIN Clause with Offline Views

155820  (http://kbalertz.com/Feedback.aspx?kbNumber=155820/EN-US/ ) How To Refreshing an Offline View in Visual FoxPro 5.0

155528  (http://kbalertz.com/Feedback.aspx?kbNumber=155528/EN-US/ ) How To Set Up an Offline View in Visual FoxPro 5.0

APPLIES TO
  • Microsoft Visual FoxPro 5.0 Standard Edition
  • Microsoft Visual FoxPro 5.0a
  • Microsoft Visual FoxPro 6.0 Professional Edition
  • Microsoft Data Access Components 2.5
Keywords: 
kbdatabase kbhowto KB192857
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate