LOCAL nRecCount, nLogicalSize, nPhysicalSize, nHandler, i CLOSE TABLES all CLOSE DATABASES ALL DELETE FILE c:\VFP8new\test_tbl.dbf DELETE FILE c:\VFP8new\test_db.dbc DELETE FILE c:\VFP8new\test_db.dct DELETE FILE c:\VFP8new\test_db.dcx SET TABLEVALIDATE TO 2 && <-------- or 0 SET MULTILOCKS ON CREATE DATABASE c:\VFP8new\test_db CREATE TABLE c:\VFP8new\test_tbl (one_field N(1,0)) ? 'FileSize after create: ', HEADER() + 1 ? =CURSORSETPROP("Buffering",5) FOR i = 1 TO 5 INSERT INTO c:\VFP8new\test_tbl (one_field) VALUES (i) ENDfor =TABLEUPDATE(.T.) * Check size before corruption. *SELECT test_tbl nRecCount = RECCOUNT() nLogicalSize = HEADER() + (nRecCount * RECSIZE()) + 1 USE IN test_tbl nHandler = FOPEN('c:\VFP8new\test_tbl.dbf', 2) nPhysicalSize = FSEEK(nHandler, 0, 2) FCLOSE(nHandler) ? 'BEFORE CORRUPTION' ? 'Record count: ', nRecCount ? 'Logical size: ', nLogicalSize ? 'Physical size:', nPhysicalSize * Manually decrease the record count in the table header. * Normally it would happen accidentally after some power * or network failures. ? ? 'Simulating table corruption...' * Open table for R/W, buffered nHandler = FOPEN('c:\VFP8new\test_tbl.dbf', 2) FSEEK(nHandler, 4) FWRITE(nHandler, CHR(4)) && <------- or 3 FCLOSE(nHandler) * Check size after corruption USE c:\VFP8new\test_tbl nRecCount = RECCOUNT() nLogicalSize = HEADER() + (nRecCount * RECSIZE()) + 1 USE IN test_tbl nHandler = FOPEN('c:\VFP8new\test_tbl.dbf', 2) nPhysicalSize = FSEEK(nHandler, 0, 2) FCLOSE(nHandler) ? ? 'AFTER CORRUPTION' ? 'Record count: ', nRecCount ? 'Logical size: ', nLogicalSize ? 'Physical size:', nPhysicalSize * I will try inserting a record - NO transaction. ? ? 'Inserting new record...' USE c:\VFP8new\test_tbl SHARED =CURSORSETPROP("Buffering",5) *BEGIN TRANSACTION INSERT INTO c:\VFP8new\test_tbl VALUES (6) =TABLEUPDATE(.T.) FLUSH WAIT TIMEOUT 5 "Waiting 5 seconds" *END TRANSACTION ? 'No error:', ERROR() * Check size after insert nRecCount = RECCOUNT() nLogicalSize = HEADER() + (nRecCount * RECSIZE()) + 1 USE IN test_tbl nHandler = FOPEN('c:\VFP8new\test_tbl.dbf', 2) nPhysicalSize = FSEEK(nHandler, 0, 2) FCLOSE(nHandler) ? ? 'AFTER INSERTION' ? 'Record count: ', nRecCount ? 'Logical size: ', nLogicalSize ? 'Physical size:', nPhysicalSize ? 'VFP discarded insert operation.' CLOSE DATA ALL