using SQLite database for smart device VS 2008

611 views Asked by At

I'm developing an application for my WindowsCE packect PC(.netCF35) to read some parameters and record them in my SQLite database in Visual Studio 2008. I knew that I need to add SQLite references to my application (I had a succeed experience for my windows 7 application). So I downloaded related files from http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki and I just could add System.Data.SQLite.dll (I couldn't add SQLite.Interop.102.dll to my references). Now when I run my application, I can't add any data to my database and it seems cmdwrite.ExecuteNonQuery(); doesn't work correct. I need to say my table name and structure is correct(I'm sure). You can see my code as follow:

SQLiteConnection con = new SQLiteConnection("Data Source=AMI.sqlite;Version=3;");

public bool Insert(string Meter_ID, string type, string readout, string timestamp)
    {
        sqlwrite = "INSERT INTO meters (id,type,val,timestamp) VALUES(?,?,?,?)";
        try
        {
            SQLiteCommand cmdwrite = new SQLiteCommand(sqlwrite, con);
            cmdwrite.Parameters.AddWithValue("@id", Meter_ID);
            cmdwrite.Parameters.AddWithValue("@type", type);
            cmdwrite.Parameters.AddWithValue("@val", readout);
            cmdwrite.Parameters.AddWithValue("@timestamp", timestamp);

            con.Open();
            dbstate = "3";
            cmdwrite.ExecuteNonQuery();
            dbstate = "4";
            con.Close();
            return true;
        }
        catch
        {
            con.Close();
            return false;
        }
    }
Insert("123", "456", "789", "123");

Does anybody have any experience to work with SQLite database in WindowsCE?

0

There are 0 answers