SQLiteConnection语句错误

标签 sqlite

我在这条以 SQLiteConnection 开头的行下面看到一个蓝色的波浪线,不知道我错过了什么。我正在使用 SQLiteAsyncConnection,因为我在某处读到它不支持像 InsertWithChildren 这样的方法,所以想到尝试 SQLiteConnection 类。

string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");
    SQLiteConnection db = new SQLiteConnection(dbPath);

这些是我上面的 using 语句:

using SQLite.Net;
using SQLiteNetExtensions.Extensions;

这是我收到的错误消息

Error 2 'SQLite.Net.SQLiteConnection' does not contain a constructor that takes 1 arguments D:\OneDrive\Projects\SQLiteAsyncConnection Class\sqlite-net\MainPage.xaml.cs 28 31 sqlite-net

最佳答案

您正在使用另一个库的构造函数 - 基本的“sqlite-net”仅需要一个参数构造函数,但 SQLite.Net 也需要一个平台参数。 Here您可以找到文档和构造函数示例:

public class Database : SQLiteConnection
{
    private const string DATABASE_NAME = "sqlite.db";
    private static ISQLitePlatform platform = new SQLitePlatformWin32();

    public Database()
        : base(platform, DATABASE_NAME)
    {
        CreateTable<ClassExample>();
    }
}

关于SQLiteConnection语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29860581/

相关文章:

android,删除sqlite中的多行

database - 如何在 sqflite 的数据库中创建多个表?

Android线程和数据库锁定

mysql - 如何在一个更新sql查询中乘以当前数据库行值

sql - 如何使用默认值在 SQLite 中插入行?

php - 在 SQLITE SELECT 语句中使用的自定义 REGEXP 函数

sql - 在 sqlx 或数据库/sql(golang)中立即开始?

android - 如何使用 Active Android 实现插入或替换列值?

python - 如何使用 SQL 参数

python - 为什么这个 Sqlite 日期比较有效?