W
WebDevHokie
I am using reflection to create a data access component. I have the
following code:
SqlConnection o_Temp = new SqlConnection();
System.Data.IDbConnection o_Connection;
o_Connection = o_Temp as IDbConnection;
This works correctly but it does not use reflection. Now I am looking to
use this code:
System.Reflection.Assembly o_Assembly =
System.Reflection.Assembly.LoadWithPartialName("System.Data");
object o_Temp2 =
o_Assembly.CreateInstance("System.Data.SqlClient.SqlConnection");
System.Data.IDbConnection o_Connection;
o_Connection = o_Temp2 as IDbConnection;
This does not work as o_Connection is null when it attempts to cast. Any
idea why this would be?
Thanks in advance!
following code:
SqlConnection o_Temp = new SqlConnection();
System.Data.IDbConnection o_Connection;
o_Connection = o_Temp as IDbConnection;
This works correctly but it does not use reflection. Now I am looking to
use this code:
System.Reflection.Assembly o_Assembly =
System.Reflection.Assembly.LoadWithPartialName("System.Data");
object o_Temp2 =
o_Assembly.CreateInstance("System.Data.SqlClient.SqlConnection");
System.Data.IDbConnection o_Connection;
o_Connection = o_Temp2 as IDbConnection;
This does not work as o_Connection is null when it attempts to cast. Any
idea why this would be?
Thanks in advance!