xamarin.forms - SQLite Xamarin.forms 不返回保存的数据
问题描述
我坚持使用 Xamarin.Forms SQLite。
我使用这个 NuGet 包:sqlite-net-pcl
我想使用以下代码将表中的数据保存到变量中
SQLiteConnection myconnection = new SQLiteConnection(Constants.DatabasePath);
SQLiteCommand cmd = new SQLiteCommand(myconnection);
myconnection.CreateTable<Modul>();
var Mods = myconnection.Query<Modul>("SELECT * FROM Modul");
Mods 返回 = Count=0; 但我已经保存了数据。点击这里
我的模块类:MoulID 在顶部有主键 [Primarykey]...
public int ModulID { get; set; }
public string Modul_Name { get; set; }
我将从这里包含我现有的数据库
与这堂课
公开课{
public const string DatabaseFilename = "VocalDB.db";
public static string DatabasePath
{
get
{
var basePath = "D:/C#-Projets/Vocabul/Vocabul/Vocabul/DataBase/";
return Path.Combine(basePath, DatabaseFilename);
}
}
}
解决方案
在您的代码中,您创建表然后执行查询...我认为创建表后该表是空的。
myconnection.CreateTable<Modul>();
var Mods = myconnection.Query<Modul>("SELECT * FROM Modul");
推荐阅读
- javascript - 基本算法脚本:返回数组中的最大数 (JavaScript)
- amazon-web-services - 无论如何,我们是否可以在 Amazon Connect 上获得来电报告以及电话号码?
- php - 如何从命令行运行 mvc 控制器操作
- sql - 使用 TD_WEEK_OF_CALENDAR 时出现 Teradata 3706 错误
- javascript - Liferay - React portlet:MIME 类型('text/html')不可执行,并且启用了严格的 MIME 类型检查
- c++ - C++ 读取包含空字符的流的行
- google-sheets - 计算 AVERAGE() 时忽略某些值
- android - 带有 Xampp 的 WebView
- ruby - Ruby:如何使用别名修改字符串的一部分
- laravel - Laravel 和 Vuejs。我可以发帖,但我无法获取数据