0
我正在制作UWP中的movieApp,如果用户喜欢电影,我想存储电影中的ID。我已经尝试过使用txt,但存在拒绝访问错误的问题。所以我决定使用sqlite保证。用SQLite插入新行PCL
我用它来获取starded: https://code.msdn.microsoft.com/windowsapps/Implement-SQLite-Local-8b13a307#content
我一直在寻找,而现在,所有信息我找到sqlite的PCL dosent工作..它看起来像许多过dosent方法存在的例子我找到用途。
因此,似乎很少有例子在那里..玛贝你们可以把我在正确的道路..
这是到目前为止我的代码为这个:
private void LikeIt()
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Filmdb.sqlite");
using (SQLite.Net.SQLiteConnection conn =
new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath))
{
if (File.Exists(sqlpath))
{
AdMovieID();
}
else
{
conn.CreateTable<MovieID>();
AdMovieID();
}
}
}
private void AdMovieID()
{
var sqlpath = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Filmdb.sqlite");
SQLite.Net.SQLiteConnection conn = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), sqlpath);
//This is where i have tried some of the things i have found
// like this:
//SQLite.Net.SQLiteCommand insertSQL =
//new SQLite.Net.SQLiteCommand("INSERT INTO MovieID(ID) VALUES(?), conn)<-- error: dosent work no constructor that takes arguments;
//insertSQL.Parameters.Add(MovieID.ID);
//Just to test if something is saved
var allaId = conn.Find<MovieID>(sqlpath).ID;//<-- just tried this and it dosent work either "Object reference not set to an instance of an object."
foreach (var id in allaId)
{
Test.Text = id.ToString();
}
}
的类我使用SQLite使用:
public class MovieID
{
public string ID { get; set; }
}
非常感谢你现在的作品! 我已经尝试了很多东西,他们有一些我有commentOut在上面的代码..但就像我说它从来没有工作.. 你是如何知道这个具体的命令?因为我无法找到任何示例显示这对于Sqlite PCL .. – Newbie1337