SQLite table corruption

The original problem start here (http://www.tinyclr.com/forum/topic?id=10217&page=2)
After some time my SQLite Table is not the same yet. Because picture means more then a thousand words I attached it. It shows two Tables in SQLite 3 database. One good and one bad.
I created tables with:

[quote]
CREATE TABLE Humidity (
DateTime DATETIME,
Humidity REAL
);
CREATE INDEX idx_Humidity ON Humidity (
DateTime COLLATE BINARY DESC
);[/quote]
It works for some time, but then boom.


        private static void TemperatureHumidity_MeasurementComplete(Gadgeteer.Modules.Matjaz.MatjazTemperatureHumidity sender, double temperature, double relativeHumidity)
        {
            if (double.IsNaN(LastTemperature) || Math.Abs(LastTemperature - temperature) >= 0.1)
            {
                temperature = MatMath.Round(temperature, 2);
                DateTime time = DateTime.Now;
                AddTemperature(time, temperature);
                if (TemperatureChanged != null)
                    TemperatureChanged(time, temperature);
                LastTemperature = temperature;
                LastDateTimeTemperature = time;
            }
            if (double.IsNaN(LastHumidity) || Math.Abs(LastHumidity - relativeHumidity) >= 1)
            {
                relativeHumidity = MatMath.Round(relativeHumidity, 2);
                DateTime time = DateTime.Now;
                AddHumidity(time, relativeHumidity);
                if (HumidityChanged != null)
                    HumidityChanged(time, relativeHumidity);
                LastHumidity = relativeHumidity;
                LastDateTimeHumidity = time;
            }
        }

        private static void AddTemperature(DateTime time, double temp)
        {
            DB.Spalnica.ExecuteNonQuery("INSERT INTO Temperature (DateTime, Temperature) VALUES ('" + time.ToString() + "','" + temp + "')");
        }

        private static void AddHumidity(DateTime time, double hum)
        {
            DB.Spalnica.ExecuteNonQuery("INSERT INTO Humidity (DateTime, Humidity) VALUES ('" + time.ToString() + "','" + hum + "')");
        }

//ExecuteNonQueryMethod is:
        public new void ExecuteNonQuery(string query)
        {
            lock (_lock)
            {
                if (!Opened)
                    Open();
                if (_AutoClosed != null)  //timer
                    _AutoClosed.Restart();
                base.ExecuteNonQuery(query);
            }
        }

I get error:

The column name is corrupted.

1 Like

That sounds fantastic. We will see after a day or two.

Thanks!
Almost give up on SQLite.

1 Like

At the moment out of time. I will not forget to reply, when I will know something.