I am using ArcMap 10.2.1. Python 2.7
I am building a script tool that updates definition queryies that I need to work on any computer. We all use the same SDE database but our connection file names vary computer to computer/ mxd to mxd. We all use a connection with network logins though.
In the tool I find all the layers that are visible and have selections, then loop through them to look for an existing definition query, get the OIDs of the selected features, and paste those in the definition query box. It works great, unless the sde connection file that was used to add the layer to the mxd can't be found on that computer. This it throws this error:
Traceback (most recent call last):
File "\\eprime\Enogexgis\Tools\PythonScripts\DefinitionQueryCalculator_choose.py", line 35, in <module>
countDefQ1 = arcpy.GetCount_management(lyr2).getOutput(0)
File "c:\program files (x86)\arcgis\desktop10.2\arcpy\arcpy\management.py", line 14483, in GetCount
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Rows: Dataset Database Connections\myDatabase\GAS\Pipesegment does not exist or is not supported
Failed to execute (GetCount).
when you look at the attached code, it is on line 35 countDefQ1 = arcpy.GetCount_management(lyr2).getOutput(0) that throws the error.
Could somebody please help me fix it so that it will always find the database?