I am trying to List the fields of each data source (which are all feature classes) of each layer in a map. The data source feature classes are SDE feature classes.
When I try this simple script:
mxd = arcpy.mapping.MapDocument(r"C:\Map_Documents\Test.mxd") df = arcpy.mapping.ListDataFrames(mxd) lyrList = arcpy.mapping.ListLayers(mxd, "", df) for lyr in lyrList: if lyr.supports("dataSource"): for field in arcpy.ListFields(lyr.dataSource): print field.name
which throws the following error:
Runtime error Traceback (most recent call last): File "<string>", line 3, in <module> File "e:\sw_nt\arcgis\desktop10.2\arcpy\arcpy\__init__.py", line 1119, in ListFields return gp.listFields(dataset, wild_card, field_type) File "e:\sw_nt\arcgis\desktop10.2\arcpy\arcpy\geoprocessing\_base.py", line 344, in listFields self._gp.ListFields(*gp_fixargs(args, True))) IOError: "C:\Documents and Settings\username\Application Data\ESRI\ArcCatalog\Connection to ThisSDE.sde\POPULATION_POINT" does not exist
indicating that the datasource does not exist. The problem is, that it does. My SDE feature classes are password protected, so i have a feeling that is why the script can't see each feature class and its associated fields. Can anyone suggest a work around to fix this?