【发布时间】:2011-04-22 14:13:06
【问题描述】:
我要运行以下代码:
$dll = [System.Reflection.Assembly]::LoadWithPartialName("System.Data.SQLite")
# [System.Reflection.Assembly]::LoadFrom("C:\Program Files\System.Data.SQLite\bin\System.Data.SQLite.dll")
$ConnectionString = "Data Source=C:\Var\sqlite_ff4\places.sqlite"
$conn = New-Object System.Data.SQLite.SQLiteConnection
$conn.ConnectionString = $ConnectionString
$conn.Open()
$sql = "SELECT * from moz_bookmarks"
$cmd = New-Object System.Data.SQLite.SQLiteCommand($sql, $conn)
# $cmd.CommandTimeout = $timeout
$ds = New-Object system.Data.DataSet
$da = New-Object System.Data.SQLite.SQLiteDataAdapter($cmd)
$da.fill($ds)
$conn.close()
$ds.tables[0]
排队
$conn.Open()
我得到了错误
Exception calling "Open" with "0" argument(s): "File opened that is not a database file
file is encrypted or is not a database"
At line:5 char:11
+ $conn.Open <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
文件 places.sqlite 来自 Firefox 4.0。我正在使用http://sourceforge.net/projects/sqlite-dotnet2/files/。
编辑:
以上内容适用于 Firefox 3.0 文件 places.sqlite。 Firefox 4.0 似乎有些不同。
好像不是密码问题,是版本问题。感谢this Stack Overflow post,我发现我需要 SQLite 3.7。
我希望我能找到一些当前的 ADO 提供商。
来自here 的 sqlite-dotnet-x86-1006900.exe 不起作用
使用“0”参数调用“Open”的异常:“无法加载 DLL 'SQLite.Inte rop.DLL': 找不到指定的模块。 (来自 HRESULT 的异常:0x8 007007E)"
这可能是一个调试版本。有没有没有 SQLite.Interop.DLL 的预编译版本?
【问题讨论】:
-
你能用其他 SQLite 工具打开这个数据库吗? sqlite3.exe 命令行实用程序(见官网下载)?
-
我可以用 SQLite Manager Firefox Addon 打开它
-
使用 sqlite3.exe places.sqlite 我得到:错误:文件已加密或不是数据库
-
只是猜测:它可能受密码保护。如果是这种情况,您需要获取它并在连接字符串中指定
Data Source=...; Password=...。
标签: sqlite powershell ado.net