I am trying to implement a SQLite database using c# and microsoft.data.sqlite in a .Net Standard 2.0 Project.
I keep getting the error "Method not found: 'IntPtr SQLitePCL.sqlite3.get_ptr()'" when I call connection.Open()
I have downloaded the following Nuget Packages:
<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>
I am executing it as follows:
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();
}
}
Everything builds. At runtime, when the following block executes, I get: "Method not found: 'IntPtr SQLitePCL.sqlite3.get_ptr()'"on Connection.Open();