DbProviderFactories.GetFactory(dbProviderName)
DBProviderFactory factory = DBProviderFactorys.GetFactory("System.Data.SqlClient"); //可通过配置改变
DBConnection conn = factory.CreateConnection();
conn.ConnectionString = .....
providerInvariantName:
System.Data.SQLite
System.Data.SqlClient
SQLite的支持,如果不支持,会报错,
找不到请求的 .Net Framework Data Provider。可能没有安装.
解决办法:
machine.config中加一个Provider配置(C:WindowsMicrosoft.NETFramework64v4.0.30319Configmachine.config),打开,约在129行,有个DbProviderFactories配置节,再添加一个SQLITE3的。如下:
<add 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