我正在尝试在 .Net Standard 2.0 项目中使用 c# 和 microsoft.data.sqlite 实现 SQLite 数据库。
当我调用 connection.Open() 时,我不断收到错误“找不到方法:'IntPtr SQLitePCL.sqlite3.get_ptr()'”
我已经下载了以下 Nuget 包:
<ItemGroup>
<PackageReference Include="Microsoft.Data.SQLite" Version="2.2.6" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="2.2.6" />
<PackageReference Include="SQLitePCLRaw.bundle_green" Version="2.0.0" />
<PackageReference Include="SQLitePCLRaw.core" Version="2.0.0" />
<PackageReference Include="SQLitePCLRaw.lib.e_sqlite3" Version="2.0.0" />
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3" Version="2.0.0" />
<PackageReference Include="SQLitePCLRaw.provider.e_sqlite3.netstandard11" Version="1.1.14" />
</ItemGroup>
我执行如下:
private static SqliteConnection _sqlConnection = new SqliteConnection(@"Data Source = myPath");
public static Int64 InsertTransaction(string stringToInsert)
{
SQLitePCL.Batteries_V2.Init();
StringBuilder sqlToExecute = new StringBuilder();
sqlToExecute.Append("INSERT INTO table");
sqlToExecute.Append("(columnName) ");
sqlToExecute.Append("VALUES(' " + stringToInsert+ "')");
using (SqliteConnection connection = _sqlConnection)
{
connection.Open();
SqliteTransaction transaction = connection.BeginTransaction();
SqliteCommand sqlCommand = new SqliteCommand(sqlToExecute.ToString(), connection, transaction);
sqlCommand.ExecuteNonQuery();
}
}
一切都建立起来了。在运行时,当执行以下块时,我得到:“未找到方法:'IntPtr SQLitePCL.sqlite3.get_ptr()'”on Connection.Open();
千万里不及你
相关分类