Microsoft OleDb Provider for Jet (Microsoft.Jet.Oledb.4.0)
<< Click to Display Table of Contents >> Microsoft OleDb Provider for Jet (Microsoft.Jet.Oledb.4.0) |
|
Problems with this provider
•We have had no problem reports for this provider
Compacting databases
There is no support in ADO or ADOX to compact a Jet database. Support for compacting Databases is build in the JRO classses. The sample below may be useful to you:
FUNCTION Start()
IF ! CompactDatabase("D:\Vo2ado\Northwind.mdb", "D:\Vo2ado\NewNorthwind.mdb")
? "Error compacting database"
ELSE
? "Compact succesful"
ENDIF
WAIT
FUNCTION CompactDatabase(cOldfile AS STRING, cTmpFile AS STRING)
LOCAL oJetEngine AS OBJECT
LOCAL cbErr AS CODEBLOCK
LOCAL lRet AS LOGIC
LOCAL oError
cbErr := ErrorBlock({"oErr"_Break(oError)})
BEGIN SEQUENCE
oJetengine := OleAutoObject{"JRO.JetEngine"}
IF ! oJetEngine:Finit
BREAK "Could not start JRO.JetEngine"
ENDIF
IF File(cTmpFile)
IF ! FErase(cTmpFile)
BREAK "Could not erase "+cTmpFile
ENDIF
ENDIF
oJetEngine:CompactDatabase("Data Source="+cOldFile+";",;
"Data Source="+cTmpFile+";")
IF ! FErase(cOldFile)
BREAK "Could not erase "+cOldFIle
ENDIF
IF ! FRename(cTmpFile, cOldFile)
BREAK "Could not Rename"
ENDIF
lRet := TRUE
RECOVER USING oError
ErrorBlock(cbErr)
lRet := FALSE
IF IsInstanceOfUsual(oError,#Error)
? oError:Description
ELSE
? AsString(oError)
ENDIF
END
ErrorBlock(cbErr)
RETURN lRet