Getting schema information in C# using ADOX

D

Developer98115

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.ActiveConnection =
sqlConnection;
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top