DOCUMENT:Q142394 10-FEB-2000 [foxpro] TITLE :PRB: CLEAR ALL Removes Back-Links from Data Environment Object PRODUCT :Microsoft FoxPro PROD/VER:WINDOWS:3.0,3.0b OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual FoxPro for Windows, versions 3.0, 3.0b ------------------------------------------------------------------------------- SYMPTOMS ======== If the CLEAR ALL command is issued with an open Data Environment Object, the back-links of the tables contained in the Data Environment are destroyed. Consecutive access of these tables will yield this error: Table 'tablename.dbf' is not marked as belonging to the 'databasename' database. Would you like to create the back link to mark it? RESOLUTION ========== The tables must be opened exclusively to properly update the back links. If the tables are not opened exclusively the following error will occur in the Init event of the DataEnvironment class: File must be opened exclusively. To work around this behavior, be sure to release all DataEnvironment objects before issuing the CLEAR ALL command. STATUS ====== This behavior is by design. MORE INFORMATION ================ Data Environments can be classed programatically. Once instantiated, you may issue the CLEAR ALL command with open tables and database containers. If the CLEAR ALL command is issued with an open Data Environment Object, the tables open at that time lose their links to the database container. This does not occur with forms' Data Environments. Code to Demonstrate Behavior ---------------------------- The following program demonstrates this behavior. Each time this program is run subsequent to the first time, Visual FoxPro produces the error listed above for each table that the DataEnvironment class defines. SET DEFAULT TO c:\vfp CLOSE DATA oDe = CreateObject('de') CLEAR ALL && remove this line, and run the program twice to && resolve the problem DEFINE CLASS de AS DataEnvironment Name = "DE" AutoCloseTables = .F. AutoOpenTables = .T. InitialSelectedAlias = "customer" ADD OBJECT oCustomer AS cursor WITH ; Alias = 'customer', ; Database = CURDIR() + 'samples\data\testdata.dbc', ; CursorSource = 'customer', ; Exclusive = .T. PROCEDURE Init THIS.OpenTables ENDPROC ENDDEFINE Additional query words: VFoxWin ====================================================================== Keywords : Technology : kbVFPsearch kbAudDeveloper kbVFP300 kbVFP300b Version : WINDOWS:3.0,3.0b ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2000.