【发布时间】:2019-04-21 11:46:36
【问题描述】:
我想将一个 asp.net Web 表单项目连接到一个 sqlite 数据库,所以我创建了一个 Dbase.cs 类来处理 sql 命令。 在使用 Nuget 包含 System.Data.SQLite 提供程序后,我收到以下错误 - 无法加载 DLL 'SQLite.Interop.dll':找不到指定的模块。
我读到我需要指定正确的架构 (x64/x86),但我似乎无法在任何地方找到 SQLite.Interop.dll 文件。 我需要为我的平台安装二进制包以外的东西吗?
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();
}
}
【问题讨论】: