SQLite standard example

I am trying to create a database with SQLite with C #, then I create the table insert data, and then close the connection. I just downloaded System.Data.SQLite.dll lybrary and I'm not sure how to use it. There are many examples on the Internet, but all of them seem to have a database. Or maybe I'm doing something wrong.

Good. If I have a short example, just create a database, table and base query.

EDIT

I tried the examples provided by the comments, but I do not understand why I am getting errors. Maybe I downloaded the wrong library? enter image description here

+4
source share
3 answers

The error was due to the fact that I used the .NET Framework 4.0. I dropped to 2.0 and it worked. Sorry for the question. It would be nice to use it with the .NET Framework 4.0.


Edit:

It really works with the .NET Framework 4.0. I had to add these lines of code to the app.config file:

<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0.30319" sku=".NETFramework,Version=v4.0,Profile=Client" /> </startup> 

Also, if you plan to use ado.net in your solution, I have many deployment problems. Everything worked perfectly on development. If you are using ado.net and plan to deploy your application, include also:

 <!--Sqlite configuration so that it works with ado.net--> <system.data> <DbProviderFactories> <remove invariant="System.Data.SQLite"/> <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /> </DbProviderFactories> </system.data> 

if you include this last part in the app.config file, you need to make sure that:

enter image description here

these dlls should be in your output directory.

when deploying, make sure you copy these files to the working directory

+3
source

shouldn't be {"FailIfMissing", "False"} instead of {"FailIfMissing=False", "False"} ?

0
source

Change the platform target for your C # project to "Project Settings"> "Create"> "Platform Target": any processor.

I had a similar error when I tried to run SQLite x64 binaries on an x64 machine. But it worked fine after these settings were changed

0
source

All Articles