By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,243 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,243 IT Pros & Developers. It's quick & easy.

Getting schema information in C# using ADOX

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.