C # dbproviderfactories Multi-database support engineering mode

Source: Internet
Author: User
Tags sqlite

Dbproviderfactories.getfactory (Dbprovidername)

DbProviderFactory factory = dbproviderfactorys.getfactory ("System.Data.SqlClient"); Can be changed by configuration
DBConnection conn = Factory. CreateConnection ();
Conn. ConnectionString = .....

Providerinvariantname:

System.Data.SQLite

System.Data.SqlClient

SQLite support, if not supported, will error,

The requested. Net Framework Data Provider could not be found. may not be installed.

Workaround:

Add a provider configuration in Machine.config (C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\ Machine.config), open, about 129 lines, there is a DbProviderFactories configuration section, and then add a SQLITE3. As follows:

<name= "SQLite3 Data Provider"  invariant= "System.Data.SQLite" Description = ". NET Framework Data Provider for sqlite3.x" type = "System.Data.SQLite.SQLiteFactory, System.Data.SQLite, version=1.0.66.0, Culture=neutral, publickeytoken= db937bc2d44ff139 "/>

Http://www.cnblogs.com/Don/p/3633098.html

C # dbproviderfactories Multi-database support engineering mode

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.