Skip to content

Instantly share code, notes, and snippets.

@alamsal
Created April 7, 2015 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alamsal/221a238dbfdd217d85ae to your computer and use it in GitHub Desktop.
Save alamsal/221a238dbfdd217d85ae to your computer and use it in GitHub Desktop.
Update GDB tables
IMxDocument pMxDocument = ArcMap.Application.Document as IMxDocument;
IMap pMap = pMxDocument.FocusMap;
ILayer pLayer = pMap.get_Layer(0);
IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IFields pFields = (IFields)pFeatureClass;
ITable pTable = (ITable)pFeatureClass;
ICursor pCursor = pTable.Search(null, false);
IRow pRow = pCursor.NextRow();
while (pRow != null)
{
string.IsNullOrEmpty(output);
for (int i = 0; i <= pFields.FieldCount - 1; i++) {
output += pFields.Field(i).Name + ": " + pRow.Value(i).ToString + Constants.vbNewLine;
}
MessageBox.Show(pRow.get_Value(fldIndex).ToString());
pRow = pCursor.NextRow();
}
IMxDocument pMxDocument = ArcMap.Application.Document as IMxDocument;
IMap pMap = pMxDocument.FocusMap;
ILayer pLayer = pMap.get_Layer(0);
IFeatureLayer pFeatureLayer = (IFeatureLayer)pLayer;
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
IFields pFields = (IFields)pFeatureClass;
ITable pTable = (ITable)pFeatureClass;
ICursor pCursor = pTable.Search(null, false);
string[] FieldNames = {"Name", "Address", "City"};
string output = null;
IRow pRow = pCursor.NextRow();
while (pRow != null)
{
string.IsNullOrEmpty(output);
foreach (string fieldName in FieldNames) {
output += fieldName + ": " + pRow.Value(pFields.FindField(fieldName)).ToString + Constants.vbNewLine;
}
MessageBox.Show(output);
pRow = pCursor.NextRow();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment