我正在为我的WindowsCE packect PC(.netCF35)开发一个应用程序来读取一些参数并将它们记录在Visual Studio 2008中的SQLite数据库中。我知道我需要在我的应用程序中添加SQLite引用(我有一个成功体验我的Windows 7应用程序)。所以我从http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki下载了相关文件,我只能添加 System.Data.SQLite.dll (我无法添加 SQLite.Interop.102.dll 我的参考资料)。现在当我运行我的应用程序时,我无法向我的数据库添加任何数据,而且似乎 cmdwrite.ExecuteNonQuery(); 无法正常运行。我需要说我的表名和结构是正确的(我敢肯定)。您可以看到我的代码如下:
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");
有没有人有经验在WindowsCE中使用SQLite数据库?