sqlite3.dll和system.data.sqlite.dll

时间:2009-05-07 12:45:42

标签: c# sqlite

大家好,我一直在努力在我的C#2.0应用程序中使用sqlite,我终于决定摆脱假设并提出真正的基本问题。

当我创建一个数据库说iagency与表用户,从外部工具,如firefox插件和另一个sqladmin工具我无法从sqlicommand查询它vs2005内显示System.Data.SQLite.SQLiteException:Sqlite Error no such table users,请放心,我已经做对使用SQLite-1.0.61.0-setup

安装的system.data.sqlite的引用

当我执行相反操作时,例如从VS服务器资源管理器和VS数据库gui工具创建数据库和表时,它既不能被查询,也不能被其他工具查看,但是使用stringbuilder通过查询创建的表,例如create表bla bla。它可以显示在数据网格中,但没有任何工具可以查看和显示该表。

  

我需要什么才能使SQLITE在我的应用程序中工作?

我尝试在sqlite网站下面的sqlitedll-3_6_14.zip下添加sqlite3.dll作为我的应用程序的参考,但是在{@ 1}}的情况下它已经失败了。

5 个答案:

答案 0 :(得分:11)

我下载了这个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"]);
            }
        }
    }
}

答案 1 :(得分:3)

尝试在命令行SQLite工具(来自SQLite.org)中打开数据库,并检查架构。

您可以通过以下方式检查架构:

.schema

这将转储在数据库中创建表所需的所有SQL。确保表格在那里,并假设它应具有的名称。

您不需要SQLite.org中的.dll文件,您只需要System.Data.SQLite的程序集。

答案 2 :(得分:2)

对我来说 - this链接在开始时提供了很多帮助。

更难获得亚音速工作,通过网络应用程序访问数据库 -
但这是另一个故事。

答案 3 :(得分:0)

您可以尝试将程序集和db的位置添加到Path环境变量中。 SQLite程序集包含.Net和本机代码合并在一起,因此您不需要C dll。 (他们包含的合并工具非常有趣)

答案 4 :(得分:0)

我还尝试将位置添加到 Path环境变量,但没有成功。

最后,我将System.Data.SQLite.dllSystem.Data.SQLite.lib复制到其他程序集所在的Web应用程序的bin文件夹中,并且应用程序正常工作。