Reputation: 133
I have migrated my .net 2.0
projects to .net 4.0
.
With this I had to upgrade system.data.sqlite
libraries to the latest versions available 1.0.81
.
Right now when I try to query large tables using select * from table
I get The database disk image is malformed
error. This only happens on tables with lots of records, small tables return records.
Please note if I go back to .net 2.0
and system.data.sqlite 1.0.66
the same DB file works perfecly.
Any Ideas?
Upvotes: 3
Views: 18084
Reputation: 2041
Also encountered a similar problem recently. Even after updating all AColumn values in ATable table to a new value e.g 2 using the following query
UPDATE ATable SET AColumn = 2;
the following select distinct query
SELECT DISTINCT AColumn from ATable;
returned old values e.g. 1,2,3, and
SELECT * FROM ATable WHERE AColumn = 1
resulted in a "The database disk image is malformed sqlite" error.
ATable had an index on AColumn and all the queries going through that index returned wrong result. Running integrity check using the following PRAGMA proved that some indexes were corrupt.
PRAGMA integrity_check;
IDX_AColumn was missing a lot of rows and the index also contained wrong number of entries. Luckily data in all the tables was intact, only a few indexes were corrupt. Reindexing the corrupt indexes solved problem.
REINDEX ATable; http://www.sqlite.org/lang_reindex.html
If a lot of indexes are corrupt you can reindex all of then at the same time using command:
REINDEX;
Upvotes: 7
Reputation: 133
i done some tests and found out that actually its just a little operation that resolves it.
pretty stupid.
hope this helps any body that is stuck with same problem.
Upvotes: 2
Reputation: 180070
Your database file is corrupted, the older SQLite version just doesn't detect this.
Create a new database file with data from your backup (or with as much data as you can scrape out of the old DB).
Upvotes: 3