About "Configuring" SQLite issues in C #

Source: Internet
Author: User
Tags connectionstrings

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 #

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.