Table corrupted when connection to database terminated during updating database
Posted on 2001-07-01
Platform: Win98(client), Windows NT 4.0 (server)
Development software: MS Visual Basic 6.0
Other: ODBC Visual FoxPro driver version 6.00.8428.00 or 6.00.8167.00 or 6.01.8629.01,
VB6.0 references: MS ADO 2.0 library
Steps to Reproduce Behavior
Create a database with some dummy tables using MS Visual Foxpro 6.0. In this example, the table used
is 'table1' table with fields: field1 (numeric, size 10, primary keys) and field2(character, size 4).
Table must have primary keys. Situated the database in a PC as server (file server) and the following
codes is executed in another PC as client. Program in client side will running this VB program using
ADO 2.0 to access to the database in another PC via ODBC Visual Foxpro driver in the client PC.
Run following codes.
Dim cnn1 As New ADODB.Connection
Dim rs1 As New Recordset
Dim i As Integer
Set rs1 = cnn1.Execute("Select * from table1")
For i = 1 To 10000
rs1!field1 = i
rs1!field2 = "test"
During execution of the transaction, update table1, interrupt the transaction by
1) Terminate the network connection such as pull off the network cable between client PC and server
2) Cause power failure to the either PC.
The updating table (table1) will be corrupted. Possible cause, table1.dbf and table.cdx file is not
After the table is corrupted, update table on the next time does not return error noting the table had
been corrupted. Transaction is done as if there are not problem or corruption on the database. ADO or
ODBC Visual FoxPro DO NOT trigger error or detect problem when accessing/updating the corrupted table.
ADO or ODBC Visual FoxPro DO NOT be able to repair the corrupted table.
How to detect the corrupted table on the following accessing to the table. If possible, through the
same method of VB 6.0 -> ADO -> ODBC VFP -> VFP database. 'Writing a dummy data into the table and retrieve
it again to check whether the table is corrupted' is not a acceptable solution because it cause much
processing to do so and not practical for operations that update the database frequently as detection
of corrupted table must be done on fly or immediately after the occurance.
How to repair the corrupted table. If possible, through the same method of VB 6.0 -> ADO -> ODBC VFP
-> VFP database.
Open to any possible answers!!