Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Xamarin从SQLite数据库检索数据_Sqlite_Xamarin_Xamarin.forms - Fatal编程技术网

使用Xamarin从SQLite数据库检索数据

使用Xamarin从SQLite数据库检索数据,sqlite,xamarin,xamarin.forms,Sqlite,Xamarin,Xamarin.forms,我只是试图从SQLite检索数据,但我的代码既不返回值也不给出错误。请帮帮我。 到目前为止我已经完成了 var test = new List<cdProdGroup>(); var db = new SQLiteConnection(path); var test1 = db.Query<cdProdGroup>("SELECT * FROM cdProdGroup"); foreach (var item in test1) { cdProdGroup cd

我只是试图从SQLite检索数据,但我的代码既不返回值也不给出错误。请帮帮我。 到目前为止我已经完成了

var test = new List<cdProdGroup>();
var db = new SQLiteConnection(path);

var test1 = db.Query<cdProdGroup>("SELECT * FROM cdProdGroup");
foreach (var item in test1) {
    cdProdGroup cd = new cdProdGroup { 
        DIQ_PG_CD_EBS = item.DIQ_PG_CD_EBS,  
        DIQ_PG_DESC = item.DIQ_PG_DESC,  
        DVSN_CD = item.DVSN_CD
    };

    test.Add(cd);
}
我使用Xamarin进行编码

从cdProdGroup中选择*查询是不必要的,因为重新分配到一个新列表中也是不必要的

您可以简化查询,如下所示:

var db = new SQLiteConnection(path);
var test = db.Table<cdProdGroup>().ToList();

您确定数据库的路径正确吗?您确定数据库中有数据吗?你是如何播种你的数据的?它是由你的应用程序在代码中播种的,还是你用你的应用程序部署了一个预播种的数据库?它是预播种的,是的,数据库中也有数据。此外,调试器从定义whr查询的行中退出。修复了一些拼写和语法问题;更改了代码中的缩进和间距以便于阅读。出现了什么错误?请使用类似的工具打开数据库,并在其中执行SELECT*FROM CDPRODGOUP查询。如果查询有错误,它将突出显示。