Getting schema information in C# using ADOX

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Developer98115

    Getting schema information in C# using ADOX

    I need help getting schema information from an existing SQL Server
    database. My thought was that you could use ADOX via InterOp. Has
    anyone done this successfully and how? I have created a Interop
    reference to the ADOX COM component from my C# project. I am able to
    open the SqlConnection successfully but it fails with an exception
    ["No such interface supported"] when I try to set the
    ..ActiveConnect ion property of the ADOX database catalog object.
    Another strange thing I noticed is that even when you declare and
    ADOX.Catalog, the intellisense never lets you create a new
    ADOX.Catalog so I ended up creating a ADOX.CatalogCla ss instead --
    something very strange here. Thanks in advance.

    SqlConnection sqlConnection = new SqlConnection( myConnectionStr ing );
    sqlConnection.O pen();

    ADOX.Catalog databaseCatalog = new
    ADOX.CatalogCla ss()this.databa seCatalog.Activ eConnection =
    sqlConnection;
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Getting schema information in C# using ADOX

    Developer98115,

    The classes in the System.Data.Sql Client namespace are not compatable
    with ADOX. Rather, you will have to also set a reference to classic ADO,
    and create an instance of ADODB.Connectio n, which you can then pass to the
    catalog.

    The reason for the naming is to be expected. Check out the section of
    the .NET framework documentation titled "Type Library to Assembly Conversion
    Summary". Specifically, check out the section titled "Imported Type
    Conversion" which details the way that types are imported into .NET from
    COM.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - nicholas.paldin o@exisconsultin g.com


    "Developer98115 " <calvin98115@ya hoo.com> wrote in message
    news:26ea0c7c.0 309190910.7730f be0@posting.goo gle.com...[color=blue]
    > I need help getting schema information from an existing SQL Server
    > database. My thought was that you could use ADOX via InterOp. Has
    > anyone done this successfully and how? I have created a Interop
    > reference to the ADOX COM component from my C# project. I am able to
    > open the SqlConnection successfully but it fails with an exception
    > ["No such interface supported"] when I try to set the
    > .ActiveConnecti on property of the ADOX database catalog object.
    > Another strange thing I noticed is that even when you declare and
    > ADOX.Catalog, the intellisense never lets you create a new
    > ADOX.Catalog so I ended up creating a ADOX.CatalogCla ss instead --
    > something very strange here. Thanks in advance.
    >
    > SqlConnection sqlConnection = new SqlConnection( myConnectionStr ing );
    > sqlConnection.O pen();
    >
    > ADOX.Catalog databaseCatalog = new
    > ADOX.CatalogCla ss()this.databa seCatalog.Activ eConnection =
    > sqlConnection;[/color]


    Comment

    • Robert Havens

      #3
      Re: Getting schema information in C# using ADOX

      If you're after schema information why don't you just query the sys tables?


      "Developer98115 " <calvin98115@ya hoo.com> wrote in message
      news:26ea0c7c.0 309190910.7730f be0@posting.goo gle.com...[color=blue]
      > I need help getting schema information from an existing SQL Server
      > database. My thought was that you could use ADOX via InterOp. Has
      > anyone done this successfully and how? I have created a Interop
      > reference to the ADOX COM component from my C# project. I am able to
      > open the SqlConnection successfully but it fails with an exception
      > ["No such interface supported"] when I try to set the
      > .ActiveConnecti on property of the ADOX database catalog object.
      > Another strange thing I noticed is that even when you declare and
      > ADOX.Catalog, the intellisense never lets you create a new
      > ADOX.Catalog so I ended up creating a ADOX.CatalogCla ss instead --
      > something very strange here. Thanks in advance.
      >
      > SqlConnection sqlConnection = new SqlConnection( myConnectionStr ing );
      > sqlConnection.O pen();
      >
      > ADOX.Catalog databaseCatalog = new
      > ADOX.CatalogCla ss()this.databa seCatalog.Activ eConnection =
      > sqlConnection;[/color]


      Comment

      Working...