views:

516

answers:

3

I am having problems connecting to a Sqlite database through System.Data.Sqlite. I was trying to use FluentNhibernate but that didn't work, so I went back to basics but got the same error: Cannot find entry point sqlite3_open_v2 in DLL sqlite3.

This is my (fairly simple I believe) code:

using (SQLiteConnection connection = new SQLiteConnection("Data Source=Stripper.s3db;Initial Catalog=main;"))
      {
       using (SQLiteCommand cmd = new SQLiteCommand("select * from album", connection))
   {
    cmd.Connection.Open();
    object t = cmd.ExecuteScalar();
    cmd.Connection.Close();
   }
  }

I have a reference to System.Data.SQLite so everything seems fine to me. The few explanations (you can barely call them tutorials) on the internet haven't helped me out.

+2  A: 

It may be the version of Sqlite3 you are working against. The V2 methods are relatively new - introduced in v3.5

KiwiBastard
Just had this same issue on winXP and resolved it by installing the latest version of sqlite3.
aaandre
A: 

Another possible explanation is that you're using a 32 bit version of the provider in a 64 bit application.

Joel Lucsy
A: 

I just downloaded v1.0.60.0 from the System.Data.Sqlite website (sqlite.phxsoftware.com/) which leads to http://sourceforge.net/project/showfiles.php?group_id=132486. As you can see there isn't much choice, so I can't think I'm doing anything wrong there. If I am not mistaken, Sqlite3 is included in System.Data.Sqlite so one would expect it to be the good version. I am definitely working with the 32bit version on a 32bit application. I have downloaded the installer and will try with that (I was using the binaries).

Peter
works with the installer
Peter