Configure the quotation marks, just because I think it is only a few small problems, in this record, the first encounter is really a little unprepared, yesterday to today ~ finally can begin the wanton write SQLite.
OK, the first problem is that referencing a downloaded System.data.sqlite.dll warns you that you didn't care at first, causing the next problem to not be found.
Warning 1 The processor schema "MSIL" of the generated project does not match the processor schema "x86" that references "System.Data.SQLite". This mismatch can cause the runtime to fail. Consider changing the target processor architecture of your project through Configuration Manager
Remove this warning as long as the solution, right-click, properties, generate, change anycpu to X86, i.e. ok!
The second problem is to run SQLite statements, such as a connection
using (sqliteconnection con = new Sqliteconnection (CONNSTR))
{
Con. Open ();
using (sqlitecommand com = new Sqlitecommand ())
{
Com. Connection = con;
Com.commandtext = "INSERT into T_login values (' 2015 ', ' 2015 ')";
Com. ExecuteNonQuery ();
}
}
will appear: Unhandled exception of type "System.IO.FileLoadException" in PresentationCore.dll
Workaround:
Paste the following XML inside the configuration tag:
<startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0"/> </startup>
In fact, just add uselegacyv2runtimeactivationpolicy= "true" to the original <startup> tag to OK.
SQLite Connection statement: The simplest, directly to a path string connstr = @ "Data source=c:\\zhj.db";
In the configuration tag:
<connectionStrings>
<add name= "Dbconnstr" connectionstring= "Data source=c:\\zhj.db; Pooling=true; Failifmissing=false "/>
</connectionStrings>
About "Configuring" SQLite issues in C #