C# sqlite3.dll 和 system.data.sqlite.dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/834453/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
sqlite3.dll and system.data.sqlite.dll
提问by black sensei
Hello people I've been struggling to use sqlite in my C#2.0 application and I have finally decided to get rid of assumptions and ask really basic questions.
大家好,我一直在努力在我的 C#2.0 应用程序中使用 sqlite,我终于决定摆脱假设并提出非常基本的问题。
When I created a database say iagency with table users, from external tools like firefox plugging and another sqladmin tool I can't query it from sqlicommand inside vs2005 it displays System.Data.SQLite.SQLiteException:Sqlite Error no such table users
, please be assured that I've made reference to system.data.sqlite
installed with SQLite-1.0.61.0-setup
当我使用表用户创建数据库时说 iagency,从外部工具(如 firefox 插件)和另一个 sqladmin 工具我无法从 vs2005 中的 sqlicommand 查询它显示System.Data.SQLite.SQLiteException:Sqlite Error no such table users
,请放心,我已经参考system.data.sqlite
安装了 SQLite-1.0。 61.0-设置
When I do the opposite like create a database and a table from VS server explorer and VS database gui tools it can't be queried neither but can be seen by other tools, but tables created through query from VS using stringbuilder eg create table bla bla. it can be display in a datagrid but none of the tools can see and display that table.
当我做相反的事情时,比如从 VS 服务器资源管理器和 VS 数据库 gui 工具创建一个数据库和一个表,它既不能被查询,也不能被其他工具看到,但是通过 VS 使用 stringbuilder 通过查询创建的表,例如 create table bla bla . 它可以显示在数据网格中,但没有任何工具可以查看和显示该表。
WHAT DO I NEED EXACTLY TO MAKE SQLITE WORK IN MY APPLICATION?
我究竟需要什么才能使 SQLITE 在我的应用程序中工作?
I've tried to add sqlite3.dll
of sqlitedll-3_6_14.zip downloaded from sqlite site under section precompiled binaries for windows as reference to my application but it fails with make sure it's accessible an it's a valid assembly or com component
.
我试图sqlite3.dll
在 Windows 的预编译二进制文件部分下添加从 sqlite 站点下载的 sqlitedll-3_6_14.zip 作为对我的应用程序的引用,但它以make sure it's accessible an it's a valid assembly or com component
.
采纳答案by Nifle
I downloaded this SQLite-1.0.61.0-setup.exeRan the installation then I wrote this to access the firefox favorites sqlite db.
我下载了这个SQLite-1.0.61.0-setup.exe 运行安装然后我写了这个来访问 firefox 收藏夹 sqlite db。
using System.Data.SQLite; // Dont forget to add this to your project references
// If the installation worked you should find it under
// the .Net tab of the "Add Reference"-dialog
namespace sqlite_test
{
class Program
{
static void Main(string[] args)
{
var path_to_db = @"C:\places.sqlite"; // copied here to avoid long path
SQLiteConnection sqlite_connection = new SQLiteConnection("Data Source=" + path_to_db + ";Version=3;New=True;Compress=True;");
SQLiteCommand sqlite_command = sqlite_connection.CreateCommand();
sqlite_connection.Open();
sqlite_command.CommandText = "select * from moz_places";
SQLiteDataReader sqlite_datareader = sqlite_command.ExecuteReader();
while (sqlite_datareader.Read())
{
// Prints out the url field from the table:
System.Console.WriteLine(sqlite_datareader["url"]);
}
}
}
}
回答by Lasse V. Karlsen
Try opening up the database in the command line SQLite tool (from SQLite.org), and check the schema.
尝试在命令行 SQLite 工具(来自SQLite.org)中打开数据库,并检查架构。
You can check the schema in this way:
您可以通过这种方式检查架构:
.schema
This will dump out all the SQL necessary to create the tables in the database. Make sure the table is there, with the name you assume it should have.
这将转储在数据库中创建表所需的所有 SQL。确保该表在那里,并使用您认为它应该具有的名称。
You do not need the .dll file from SQLite.org, all you need is the assemblies from System.Data.SQLite.
您不需要来自 SQLite.org 的 .dll 文件,您只需要来自System.Data.SQLite的程序集。
回答by R Ubben
You might try adding the location of the assembly and the db to the Path environment variable. The SQLite assembly contains both .Net and native code merged together, so you do not need the C dll. (the mergebin tool they include to do this is pretty interesting)
您可以尝试将程序集的位置和数据库添加到 Path 环境变量中。SQLite 程序集包含合并在一起的 .Net 和本机代码,因此您不需要 C dll。(他们用来执行此操作的 mergebin 工具非常有趣)
回答by Arnis Lapsa
回答by user3790347
I also tried adding the location to Path environment variablebut without success.
我也尝试将位置添加到Path 环境变量,但没有成功。
Finally I copied System.Data.SQLite.dll
and System.Data.SQLite.lib
into the bin folder of the Web application where other assemblies are located, and application worked.
最后,我复制System.Data.SQLite.dll
和System.Data.SQLite.lib
到其他地方组件位于Web应用程序的bin文件夹和应用程序的工作。