Pay attention to the following points when using the SQLite database:

Source: Internet
Author: User
Tags connectionstrings

 

1: when using the SQLite database, it is often unable to connect to the database. In this case, check SQLite. whether the DLL has been referenced, and whether the version of the added DLL is consistent with the SQLite version used.

These two DLL files are references that must be added when SQLite is used,

 

2: in order not to find the database after SQLite is released, you need to manually set the two DLL files to be automatically copied to the local device.

Right-click and choose "attribute">"

 

3: For published websites, remember to add the following nodes under the Web. config file to access the SQLite database correctly.

<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>

4: the database is stored in the app_data directory. When the file is published, the address of the referenced file is not an absolute path and cannot be accessed:

<Connectionstrings>
<Add name = "dbentities" connectionstring = "metadata = Res: // */models. dbmodel. CSDL | res: // */models. dbmodel. SSDL | res: // */models. dbmodel. MSL; provider = system. data. SQLite; provider connection string = & quot;Data Source = | datadirectory | \ dB. DB & quot ;"Providername = "system. Data. entityclient"/>
</Connectionstrings>

 

5: When you configure an x64 machine today, the SQLite error is reported, "cocould not load file or assembly 'System. data. SQLite 'or one of its dependencies. incorrect loading formatProgram."

At first, I thought that the SQLite database could not be connected or the dll version was faulty. Later I discovered that,System. Data. SQLite is divided into x86 and x64 operating system versions. ThereforeApplication poolWin32 compatibility should be selected;

Error:

The procedure is as follows:
In the IIS manager, select application pool-click Advanced settings for the application pool in use-enable the 32-bit application to true.

 

At this time, the page is refreshed and the error is removed.

 

 

 

 

 

 

 

 

 

 

 

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.