472,146 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

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
..ActiveConnection 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.CatalogClass instead --
something very strange here. Thanks in advance.

SqlConnection sqlConnection = new SqlConnection( myConnectionString );
sqlConnection.Open();

ADOX.Catalog databaseCatalog = new
ADOX.CatalogClass()this.databaseCatalog.ActiveConn ection =
sqlConnection;
Jul 21 '05 #1
2 5440
Developer98115,

The classes in the System.Data.SqlClient namespace are not compatable
with ADOX. Rather, you will have to also set a reference to classic ADO,
and create an instance of ADODB.Connection, 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]
- ni**************@exisconsulting.com
"Developer98115" <ca*********@yahoo.com> wrote in message
news:26**************************@posting.google.c om...
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
.ActiveConnection 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.CatalogClass instead --
something very strange here. Thanks in advance.

SqlConnection sqlConnection = new SqlConnection( myConnectionString );
sqlConnection.Open();

ADOX.Catalog databaseCatalog = new
ADOX.CatalogClass()this.databaseCatalog.ActiveConn ection =
sqlConnection;

Jul 21 '05 #2
If you're after schema information why don't you just query the sys tables?
"Developer98115" <ca*********@yahoo.com> wrote in message
news:26**************************@posting.google.c om...
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
.ActiveConnection 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.CatalogClass instead --
something very strange here. Thanks in advance.

SqlConnection sqlConnection = new SqlConnection( myConnectionString );
sqlConnection.Open();

ADOX.Catalog databaseCatalog = new
ADOX.CatalogClass()this.databaseCatalog.ActiveConn ection =
sqlConnection;

Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Brandons of mass destruction | last post: by
reply views Thread by Harold Putman | last post: by
3 posts views Thread by Atif | last post: by
2 posts views Thread by Developer98115 | last post: by
2 posts views Thread by Eric | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.