配置文件中有如下配置:
<configSections>
<section name="conn" type="MySapce.SectionHandler.CustomSection,MyDll"/>
</configSections>
<conn adapterType="SqlDataAdapter" cmdType="SqlCommand" connType="SqlConnection" readerType="SqlDataReader"></conn>
或者是:
<conn adapterType="OleDbDataAdapter" cmdType="OleDbCommand" connType="OleDbConnection" readerType="OleDbDataReader"></conn>
想根据配置文件动态改变数据库连接的类别
如Sql可以切换到Access
程序中我使用Assembly assembly=Assembly.Load("System.Data.SqlClient");object o=assembly.CreateInstance("SqlConnecion")出错
使用Type t=Type.GetType("System.Data.SqlClient","SqlConnection");得到的是null我想反射获取SqlConnection实例 我该怎么做 求助!
<configSections>
<section name="conn" type="MySapce.SectionHandler.CustomSection,MyDll"/>
</configSections>
<conn adapterType="SqlDataAdapter" cmdType="SqlCommand" connType="SqlConnection" readerType="SqlDataReader"></conn>
或者是:
<conn adapterType="OleDbDataAdapter" cmdType="OleDbCommand" connType="OleDbConnection" readerType="OleDbDataReader"></conn>
想根据配置文件动态改变数据库连接的类别
如Sql可以切换到Access
程序中我使用Assembly assembly=Assembly.Load("System.Data.SqlClient");object o=assembly.CreateInstance("SqlConnecion")出错
使用Type t=Type.GetType("System.Data.SqlClient","SqlConnection");得到的是null我想反射获取SqlConnection实例 我该怎么做 求助!
假如我只有程序集名称 且知道程序集在GAC中 我该怎么去反射它
object o=assembly.CreateInstance("System.Data.SqlClient.SqlConnecion")
请再仔细看看msdn.
如果只想做多种数据库支持,方法有很多,没必要这样做啊!