我使用 SQLite 数据库
System.Data.SQLite
(NuGet 包版本 1.0.115.5)。每次我执行数据库查询时,例如:
SELECT * FROM tasks WHERE parent_task=1073 LIMIT 1;
在调试日志中收到 2 个警告:
SQLite warning (28): double-quoted string literal: "L"
SQLite warning (28): double-quoted string literal: "P"
但我什至没有在查询中使用双引号。是 sqlite 的问题还是我遗漏了什么? 或者也许有一种方法可以禁用 sqlite 警告,因为它会在我的日志中生成大量垃圾。
c#代码:
public static DataTable AsDataTable(this SelectWhere_Extends_SelectFrom q)
{
AASqlite sqlite = new();
SQLiteDataAdapter da = new($@"SELECT {q.column_list} FROM {q.table_name} WHERE {q.where} {q.limit};", sqlite.connection);
Debug.WriteLine(da.SelectCommand.CommandText);
DataTable ds = new();
da.Fill(ds);
return ds;
}
// AASQLite class
...
public AASqlite() => connection = new($"Data Source={G.DB_PATH}");
用简单的静态查询对其进行了测试。即使这样也会引发警告。
SQLiteConnection connection = new($"Data Source={G.DB_PATH}");
connection.Open();
new SQLiteCommand("select * from tasks", connection).ExecuteReader();
connection.Close();
我自己也遇到过这个问题,要解决这个问题,需要将输入数据的双引号(“”)更改为单引号('')。 带双引号: 字符串命令 = $"更新任务 SET Complete = "{complete}" WHERE id = {id}"; 带单引号: 字符串命令 = $"更新任务 SET Complete = '{complete}' WHERE id = {id}";