gpt4 book ai didi

.net - Windows Phone 8 中的 SQLite 错误 - tracker.exe 和 Winmd 文件丢失

转载 作者:搜寻专家 更新时间:2023-10-30 20:41:34 25 4
gpt4 key购买 nike

我正在处理 Windows Phone 8 应用程序,我需要将它与 Sqlite 数据库连接。我正在关注链接下方的教程。 http://www.developer.nokia.com/Community/Wiki/How_to_use_SQLite_in_Windows_Phone

我收到错误消息“tracker.exe 丢失,找不到 Sqlite.winmd。”我错过了什么吗?为什么我收到此错误。任何好的链接也被接受,并在连接 Sqlite 和 Windows Phone 时有明确的描述。提前致谢。 enter image description here

最佳答案

通过Manage NuGet packages在你的项目中添加sqlite-net,你可以在你的项目中看到Sqlite.cs和SqliteAsync.cs文件。

第 1 步:创建一个类,该类在您的数据库中称为表。

    class TableName
{
[PrimaryKey, AutoIncrement]
public int IndexNo { get; set; }
public String Name { get; set; }
public String User { get; set; }
public String LastEdit { get; set; }
}

第二步:创建数据库文件,用SQliteConnection连接并创建表

    private async void CreateDatabase()
{
bool isDatabaseExisting = false;
//Checking if database already exists
try
{
Windows.Storage.StorageFile storagefile = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFileAsync("Database.sqlite");
isDatabaseExisting = true;
}
catch
{
isDatabaseExisting = false;
}
//if not exists then creating database
if (!isDatabaseExisting)
{
String str = System.IO.Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "Database.sqlite");
SQLiteConnection conn = new SQLiteConnection(str);
conn.CreateTable<TableName>();

}
}

第 3 步:执行查询

  1. 插入值

    conn.Execute("insert into TableName(Name,User,LastEdit) values(?,?,?)",val1, val2, val3);
  2. 获取数据库

获取所有数据使用

    var result = conn.Table<TableName>().ToList();

获取一些相关数据使用

    var result = conn.Table<TableName>().Where(x => x.User == "abc").ToList();
foreach (var item in result)
{
var name=item.Name;
var user=item.User;
}

请记住,每当您想执行影响数据库的查询时,请使用 conn.Execute 语句;当您想从数据库中获取值时,您应该使用 conn.Table 查询以方便使用。您将在 SQlite 库中获得更多方法。还要记得使用 SQlite;

欲了解更多详情或索取 sample Visit Here

祝你好运

关于.net - Windows Phone 8 中的 SQLite 错误 - tracker.exe 和 Winmd 文件丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17279235/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com