Retrieve Table Datasource Type

2044
3
Jump to solution
04-23-2013 09:39 AM
Corbinde_Bruin
Occasional Contributor II
I'm trying to get at the data source type of a table in the Table of contents. I usually do this with Feature Layers which is as simple as featureLayer.DataSourceType. The ITable interface has no such property. I can't seem to get at the Table as a Layer. Is there some casting I'm not doing properly? I see the IDataSourceInformation Interface. Is that something I can use?

Any help is appreciated. If you'd like to see code I'll reply. I just need to know which objects to use.

-Corbin de Bruin
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
You have to use IStandaloneTable to get the tables in the TOC. You can QI to an IDataset to get its source

IMxDocument pMxdoc = m_application.Document;      IMap pMap = pMxdoc.FocusMap;      IStandaloneTableCollection pStandAloneTableCollection = pMap;      IStandaloneTable pStandalonetable = null;      for (int i = 0; i <= pStandAloneTableCollection.StandaloneTableCount - 1; i++)      {          pStandalonetable = pStandAloneTableCollection.StandaloneTable(i);         IDataset pDataset = (IDataset)pStandaloneTable;         Messagebox.show(pStandalonetable.Name & ": " & pDataset.Category);      } 

View solution in original post

0 Kudos
3 Replies
KenBuja
MVP Esteemed Contributor
You have to use IStandaloneTable to get the tables in the TOC. You can QI to an IDataset to get its source

IMxDocument pMxdoc = m_application.Document;      IMap pMap = pMxdoc.FocusMap;      IStandaloneTableCollection pStandAloneTableCollection = pMap;      IStandaloneTable pStandalonetable = null;      for (int i = 0; i <= pStandAloneTableCollection.StandaloneTableCount - 1; i++)      {          pStandalonetable = pStandAloneTableCollection.StandaloneTable(i);         IDataset pDataset = (IDataset)pStandaloneTable;         Messagebox.show(pStandalonetable.Name & ": " & pDataset.Category);      } 
0 Kudos
Corbinde_Bruin
Occasional Contributor II
Thank you. For future reference, how do I find lists of ArcObjects Interfaces that QI nicely?
0 Kudos
KenBuja
MVP Esteemed Contributor
If you look at the IStandaloneTable reference, click on the StandaloneTable CoClass that implements it, which takes you to the list of interfaces it works with.
0 Kudos