Hi I have a winodows CE device with a sd-flash card. The application is a collecting data from an application and to save power it goes to sleep as often as possible. Data is also collected at regular intervals (up to once every 2 minutes). The database is located on an SD-flash card.
After a boot I get the following error: Can't open database: database disk image is malformed (11) I checked the database with PRAGMA integrity_check; And this returns the following: Page 490: sqlite3BtreeInitPage() returns error code 11 Page 489 is never used Below is how I initiate the database (just parts of the source that deals with the database setup): const char *version = sqlite3_libversion(); sqlite3_enable_shared_cache(true); sqlite3_soft_heap_limit(NIP_SQLITE_SOFTHEAP_LIMIT); //Setting softheap limit to 3MB error = openDB(dbLocation); rc = exec("PRAGMA locking_mode = EXCLUSIVE;"); rc = exec("PRAGMA synchronous = FULL;"); rc = exec("PRAGMA cache_size = 1000;"); rc = exec("BEGIN;"); rc = exec("create table IF NOT EXISTS data_records ( id integer primary key autoincrement,deployment_id integer,rectime datetime,datatype integer,data blob);"); rc = exec("create index IF NOT EXISTS idx_datadate ON data_records (rectime);"); rc = exec("create index IF NOT EXISTS idx_datatype ON data_records (datatype);"); rc = exec("create index IF NOT EXISTS idx_depid ON data_records (deployment_id);"); rc = exec("create table IF NOT EXISTS deps (id integer primary key autoincrement,stime datetime,desc varchar(100),dcfg blob);"); rc = exec("create trigger IF NOT EXISTS fifo_limit_dep_rec after delete on deps begin delete from data_records where deployment_id = old.id; end;"); rc = exec("COMMIT;"); sqlite3_close(m_db); error = openDB(m_dbFileName); The exec() function is basicly: function exec() { sqlite3_prepare16_v2(m_db,query,-1,&stmt,0); sqlite3_step(stmt); sqlite3_finalize(stmt); } The openDB function is basicly: rc = sqlite3_open16((LPWSTR)((LPCTSTR)dbLocation),&m_db); sqlite3_extended_result_codes(m_db,true); sqlite3_progress_handler(m_db,10,progress_callback,NULL); rc = exec("CREATE TABLE test(id integer);"); //Just to be 100% sure that database is opened and that there are no problems. rc = exec("DROP TABLE test;"); Is this the right way to use the database or am I doing something wrong? This is a rather critical application so it is important that the database is not corrupted. It is OK if I loose a few datasamples on powerloss, but corruption is not acceptable. Best regards Jardar _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users