11: database disk image is malformed or Unrecognized database format error


Product(s): WaterGEMS, WaterCAD, HAMMER, SewerGEMS, CivilStorm, StormCAD, SewerCAD, Flowmaster
Version(s): 10.XX.XX.XX and higher
Area: Other

 

Problem

When using the "Update database cache" tool, the following error occurs:

Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

Inner Exception: Haestad.SQLite.SQLiteException: 11: database disk image is malformed

Or

The following error is generated after compacting database and opening the model:

"11: database disk image is malformed"

Or

One of the following error variations appears when trying to open or work with the model in some way:

CONNECT Edition: "Database format not recognized or read-only. It could not be opened."

FlowMaster: Unrecognized database format "C:\Users\<User name>\AppData\Local\Temp\Bentley\<project name>.fm8.mdb.$$$"

Older WaterCAD or WaterGEMS: When Validate or Compute is performed, you get the error "Unrecognized database format"

Background

This error or exception can occur when the database is corrupted in some way. When updating or compacting a database, the step "Purging elements marked as deleted…" is skipped. This step is skipped when compacting the database while the model is opened and when compacting with the model closed and selecting "Purge records to save space". The deleted elements do not get purged from the database which can sometimes result in this problem.

Solution

To resolve this notification the following options can be adopted;

Option 1: Restoring the model from backup

The first step would be to try to restore the model from the backup file.

For example, if this crash or error occurred while working on WaterGEMS, then try to locate the .WTG.SQLITE.BAK and .WTG.BAK files to restore the model from.

The steps to recover models from backup files can be found here.

If the model is successfully restored, check if you get the error or crash by going to File > Database Utilities > Update Database Cache. If the error or crash persists, then please contact Technical Support for resolution.

Option 2: Export sub-model and import it into new workspace

With this option you can simply export the entire model as a sub-model and importing it in a new workspace.

1. Select all elements in the model (Home > Drawing > Select > Select All) or manually select all elements.

2. Go to File > Export > Submodels

3. Save the .sqlite file in a separate location. Close the model.

4. Go to File > Import > Database. Browse to the location of the newly saved database file (.sqlite) and open it.

5. The exception will no longer occur.

Note: With this option there might be some minor loss of data though (things not exported to the submodel). It is better to save a backup of the model for future reference.

If the above options do not work, please contact Technical Support to repair your database. Repairing the database involves checking the integrity of the database (.SQLITE file) and re-indexing which should fix this problem.

If you are comfortable with doing so, you can try repairing the database yourself. Be sure to make a backup of the model's .SQLITE file first. This is the model's database file and is in the same folder where the model is stored, with the same base file name. Using an application that can open SQLITE files, try re-indexing all tables or run an integrity check for  the SQLITE file. There are several applications like SQLITE Export or DB Browser for SQLITE which have options to check the integrity of the database and repair it.

For .SQLITE based products/versions (where the model file is a .WTG.SQLITE or .STSW.SQLITE and not a .MDB), download and install a SQLITE viewer such as SQLITE Expert Personal and try opening the .SQLITE file. If it immediately indicates that the file cannot be opened (for example "malformed database schema"), please try to restore your backup files using the article found here.

For .MDB-based products (where the model file is a .MDB and not a .SQLITE), open Microsoft Access and use the compact and repair tool in order to repair the database. If that doesn't work or if Access itself immediately indicates it cannot read the file, please try to restore your backup files using the wiki found here .

If you are still having trouble after that please contact technical support by submitting a service request and the Development team can attempt to repair the corruption.

See Also

Can I restore a backup file of my model project or software component?