Converting ESRI ITable to .NET DataTable

April 30, 2008

Ran into this interesting ArcObjects utility class yesterday.
To convert records of an ITable to an inMemory DataTable, use ESRI.ArcGIS.Utility.Converter.ToDataSet.

This works really well for data viewing.
However this interface seems to be now depracated and replaced with ESRI.ArcGIS.ADF.
The ToDataSet method is missing in the new interface.

Sample code:
ITable table = featureWorkspace.OpenTable(tableName);
IRecordSetInit recordSetInit= new ESRI.ArcGIS.Geodatabase.RecordSetClass();
recordSetInit.SetSourceTable(table, new QueryFilterClass());
IRecordSet recordSet= recordSetInit as IRecordSet;

System.Data.DataSet netDS = ESRI.ArcGIS.Utility.Converter.ToDataSet(recordSet);

Advertisements