I want to connect an asp.net web forms project to a sqlite database so I created a Dbase.cs class to handle sql commands. after including the System.Data.SQLite provider with Nuget I get thefollowing error - Unable to load DLL 'SQLite.Interop.dll': The specified module could not be found.
I read that I need to specify the correct architecture (x64/x86) but I cannot seem to find the SQLite.Interop.dll file anywhere. Do I need to install something other than the binary bundle for my platform?
Dbase.cs:
using System;
using System.Data;
using System.Web;
using System.Data.SQLite;
public class Dbase
{
public Dbase()
{
}
public static SQLiteConnection MakeConnection(string dbFile = "DB.sqlite")
{
SQLiteConnection c = new SQLiteConnection();
c.ConnectionString = "Data Source=" +
HttpContext.Current.Server.MapPath("~/App_Data/" + dbFile) +
";Version=3;";
c.Open();
return c;
}
public static DataTable SelectFromTable(string strSQLite, string FileName = "DB.sqlite")
{
SQLiteConnection c = MakeConnection(FileName);
SQLiteCommand comm = new SQLiteCommand();
comm.CommandText = strSQLite;
comm.Connection = c;
DataTable dt = new DataTable();
SQLiteDataAdapter da = new SQLiteDataAdapter(comm);
da.Fill(dt);
c.Close();
return dt;
}
public static void ChangeTable(string strSQLite, string FileName = "DB.sqlite")
{
SQLiteConnection c = MakeConnection(FileName);
SQLiteCommand comm = new SQLiteCommand();
comm.CommandText = strSQLite;
comm.Connection = c;
comm.ExecuteNonQuery();
c.Close();
}
}