2

I want to run the following code:

$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]

At the line

$conn.Open()

I get the error

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

The file places.sqlite is from Firefox 4.0. I'm using http://sourceforge.net/projects/sqlite-dotnet2/files/.

EDIT:

The above works for the Firefox 3.0 file places.sqlite. Something seems to be different with Firefox 4.0.

It doesn't seem to be a password problem, but a version problem. Thanks to this Stack Overflow post I found, that I need SQLite 3.7.

I hope I find some current ADO provider.

sqlite-dotnet-x86-1006900.exe from here doesn't work

Exception calling "Open" with "0" argument(s): "Unable to load DLL 'SQLite.Inte rop.DLL': The specified module could not be found. (Exception from HRESULT: 0x8 007007E)"

It is possibly a debug build. Are there any prebuild version without an SQLite.Interop.DLL?

Community
  • 1
  • 1
bernd_k
  • 11,558
  • 7
  • 45
  • 64

1 Answers1

1

Finally solved (by work around of not installing in GAC):

To open Firefox 4.0 places.sqlite you must use a version 3.7 or upper from sqlite.

I installed sqlite-dotnet-x86-1007000.exe from here, but did not check the install in GAC checkbox. Install in GAC is still faulty.

Now the following PowerShell Code works fine on a copy of places.sqlite (remember you can't open it while locked by Firefox):

# adapt these two lines to your loacal system
[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)
$ds=New-Object system.Data.DataSet
$da=New-Object System.Data.SQLite.SQLiteDataAdapter($cmd)
$da.fill($ds) 
$conn.close()
$ds.tables[0]

Since sqlite-dotnet-x86-1006900.exe they spitted SQLite.Interop.dll from System.Data.SQLite.dll, but had problems with installing it in GAC. If you check the install in GAC checkbox, you get an Unable to load DLL 'SQLite.Interop.DLL error. There is a closed ticket for this error, but I think it is not fixed. The ticket is reopened again. check there for new work arounds or solutions.

bernd_k
  • 11,558
  • 7
  • 45
  • 64
  • Did you check the option "GAC" on installation? Try to do this and then use the workaround (it was me BTW who posted that, so I did try this, it worked for me). – Roman Kuzmin Apr 22 '11 at 20:56
  • Yes I tried it. The other dllS go to C:\Windows\assembly, but SQLite.Interop.dll is missing. Going back to the old version to develop my scripts until there is a fixed precompiled version. I don't want to spend time compiling it myself. – bernd_k Apr 23 '11 at 06:27