Re: Reflection and SqlConnection

Discussion in 'ASP .Net' started by WebDevHokie, Jul 10, 2003.

  1. WebDevHokie

    WebDevHokie Guest

    It is in the System.Data assembly. I tried System.Data.SqlClient first and
    then switched to System.Data and that worked.

    In the debugger, it shows me that it creates the SqlConnection correctly,
    its just when it tries to cast it fails.

    Thanks

    WebDevHokie


    "Tu-Thach" <> wrote in message
    news:00b301c34711$3e8dea90$...
    > Could it be that the assembly for SqlClient is
    > System.Data.SqlClient.dll instead of just System.Data.dll?
    >
    > Tu-Thach
    >
    > >-----Original Message-----
    > >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!
    > >
    > >
    > >.
    > >
    WebDevHokie, Jul 10, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mark

    Can't open a SqlConnection

    Mark, May 9, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    722
  2. Nick
    Replies:
    0
    Views:
    418
  3. WebDevHokie

    Re: Reflection and SqlConnection

    WebDevHokie, Jul 10, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    405
    WebDevHokie
    Jul 10, 2003
  4. William F. Robertson, Jr.

    Re: vbc cant find system.data.sqlClient.sqlConnection

    William F. Robertson, Jr., Jul 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    653
    William F. Robertson, Jr.
    Jul 28, 2003
  5. William \(Bill\) Vaughn

    Re: SqlConnection and connection pooling

    William \(Bill\) Vaughn, Nov 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    488
    William \(Bill\) Vaughn
    Nov 14, 2003
Loading...

Share This Page