C# Windows应用商店应用程序中的SQLite查询不返回任何内容
正如我在标题中所说的,我编写的查询没有返回任何内容,而同样的查询在Valentina Studio中尝试检查数据库工作是否正常,我不明白出了什么问题。 代码如下:C# Windows应用商店应用程序中的SQLite查询不返回任何内容,c#,sqlite,windows-store-apps,C#,Sqlite,Windows Store Apps,正如我在标题中所说的,我编写的查询没有返回任何内容,而同样的查询在Valentina Studio中尝试检查数据库工作是否正常,我不明白出了什么问题。 代码如下: using System; using System.Collections.Generic; using System.Text; using SQLite; namespace SQLite_Analizer { public class sqlite_master { public string
using System;
using System.Collections.Generic;
using System.Text;
using SQLite;
namespace SQLite_Analizer
{
public class sqlite_master
{
public string name { get; set; }
}
public class manager
{
public List<string> GetListTables(string DBName)
{
List<string> tablesList = new List<string>();
string itemName = null;
var con = new SQLiteAsyncConnection(DBName);
var query = con.QueryAsync<sqlite_master>("SELECT name FROM sqlite_master WHERE type='table' AND NOT SUBSTR(name,1,6) = 'sqlite' ORDER BY name").GetAwaiter().GetResult();
foreach(var tablesItem in query)
{
itemName = "\n" + tablesItem.name + "\n\n";
tablesList.Add(itemName);
}
return tablesList;
}
}
}
使用系统;
使用System.Collections.Generic;
使用系统文本;
使用SQLite;
名称空间SQLite_分析器
{
公共类sqlite_主机
{
公共字符串名称{get;set;}
}
公共班级经理
{
公共列表GetListTables(字符串DBName)
{
List tablesList=新列表();
字符串itemName=null;
var con=新的SQLiteAsyncConnection(DBName);
var query=con.querysync(“从sqlite_master中选择名称,其中type='table',而不是SUBSTR(name,1,6)='sqlite'按名称排序”).GetAwaiter().GetResult();
foreach(查询中的var tablesItem)
{
itemName=“\n”+tableItem.name+”\n\n”;
tableList.Add(itemName);
}
返回表列表;
}
}
}
这里的新代码用一个计数器来检查查询结果的编号
using System;
using System.Collections.Generic;
using System.Text;
using SQLite;
namespace SQLite_Analizer
{
public class sqlite_master
{
public string name { get; set; }
}
public class manager
{
private List<string> tablesList;
private int count;
public manager()
{
tablesList = new List<string>();
count = 0;
}
public List<string> getList()
{
return tablesList;
}
public int getCount()
{
return count;
}
public async void GetListTables(string DBName)
{
string itemName = null;
var con = new SQLiteAsyncConnection(DBName);
var query = await con.QueryAsync<sqlite_master>("SELECT name FROM sqlite_master WHERE type='table' AND NOT SUBSTR(name,1,6) = 'sqlite' ORDER BY name");
foreach (var tablesItem in query)
{
itemName = "\n" + tablesItem.name + "\n\n";
tablesList.Add(itemName);
}
count = query.Count;
}
}
}
使用系统;
使用System.Collections.Generic;
使用系统文本;
使用SQLite;
名称空间SQLite_分析器
{
公共类sqlite_主机
{
公共字符串名称{get;set;}
}
公共班级经理
{
私人名单;
私人整数计数;
公共经理()
{
tableList=新列表();
计数=0;
}
公共列表getList()
{
返回表列表;
}
public int getCount()
{
返回计数;
}
公共异步void GetListTables(字符串DBName)
{
字符串itemName=null;
var con=新的SQLiteAsyncConnection(DBName);
var query=wait con.querysync(“从sqlite_master中选择名称,其中type='table',而不是SUBSTR(名称,1,6)='sqlite'按名称排序”);
foreach(查询中的var tablesItem)
{
itemName=“\n”+tableItem.name+”\n\n”;
tableList.Add(itemName);
}
count=query.count;
}
}
}
我想试试这样的东西
public async List<string> GetListTables(string DBName)
{
List<string> tablesList = new List<string>();
string itemName = null;
var con = new SQLiteAsyncConnection(DBName);
var query = await con.QueryAsync<sqlite_master>("SELECT name FROM sqlite_master WHERE type='table' AND NOT SUBSTR(name,1,6) = 'sqlite' ORDER BY name");
foreach(var tablesItem in query)
{
itemName = "\n" + tablesItem.name + "\n\n";
tablesList.Add(itemName);
}
return tablesList;
}
公共异步列表GetListTables(字符串DBName)
{
List tablesList=新列表();
字符串itemName=null;
var con=新的SQLiteAsyncConnection(DBName);
var query=wait con.querysync(“从sqlite_master中选择名称,其中type='table',而不是SUBSTR(名称,1,6)='sqlite'按名称排序”);
foreach(查询中的var tablesItem)
{
itemName=“\n”+tableItem.name+”\n\n”;
tableList.Add(itemName);
}
返回表列表;
}
更改了代码,但仍然没有更改。