[英]sqlite3.dll and system.data.sqlite.dll
大家好,我一直在努力在我的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工具创建一个数据库和一个表时,它既不能被查询,也不能被其他工具查看,但是通过查询从VS使用stringbuilder创建表格,例如create table bla bla 。 它可以显示在数据网格中,但没有一个工具可以查看和显示该表。
在我的应用程序中,我需要做什么才能使SQLITE工作?
我试图添加从sqlite站点下载的sqlitedll-3_6_14.zip的sqlite3.dll
作为我的应用程序的参考预编译二进制文件,但它失败了, make sure it's accessible an it's a valid assembly or com component
。
我下载了这个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"]);
}
}
}
}
尝试在命令行SQLite工具(来自SQLite.org )中打开数据库,并检查架构。
您可以通过以下方式检查架构:
.schema
这将转储在数据库中创建表所需的所有SQL。 确保表格在那里,并假设它应具有的名称。
您不需要SQLite.org中的.dll文件,您只需要System.Data.SQLite中的程序集。
对我来说 - 这个链接在开始时提供了很多帮助。
更难获得亚音速工作,通过Web应用程序访问数据库 -
但这是另一个故事。
我也尝试将位置添加到Path环境变量但没有成功。
最后,我将System.Data.SQLite.dll
和System.Data.SQLite.lib
复制到其他程序集所在的Web应用程序的bin文件夹中,并且应用程序正常工作。
您可以尝试将程序集和db的位置添加到Path环境变量中。 SQLite程序集包含.Net和本机代码合并在一起,因此您不需要C dll。 (他们包含的合并工具非常有趣)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.