Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite.Interop.DLL How to use non managed DLL

Tags:

c#

sqlite

ado.net

I would like to use System.Data.SQLite with an wpf application. So I dowloaded the files here and add the reference to System.Data.SQLite downloaded.

Then I write the code

 SQLiteConnection connex = new SQLiteConnection(@"Data Source=C:\Users\Toto\Desktop\Test.sqlite;");
        connex.Open();
        DataTable dt = new DataTable();
        SQLiteCommand command = connex.CreateCommand();
        command.CommandText = "SELECT * FROM TEST";
        SQLiteDataAdapter da = new SQLiteDataAdapter();
        da.SelectCommand = command;
        da.Fill(dt);
        connex.Close();

But It doesn't work.. When I try to open the connexion, it says that it is impossible to find the SQLite.Interop.dll.. No problem I have this one but impossible to add reference to it because it is an unmanaged DLL.

So, if someone is used to use SQLite and ADO.NET I'm looking for advices..

Thanks a lot

like image 873
bAN Avatar asked Jun 19 '11 15:06

bAN


1 Answers

You just need to copy the unmanaged DLL to the same folder as your EXE.

like image 184
SLaks Avatar answered Nov 16 '22 17:11

SLaks