getting "bad connection handle" after arcpy.SelectLayerByAttribute_management()

7511
5
08-18-2014 03:36 PM
GeorgeRiner
New Contributor III

I've switched my TOC source to a version in our SDE server. I then execute a simple python script to select rows by attribute. The selection works, but then all redraws of the map throw up a dialog box titled "ArcMap Drawing Errors". The box contains a line for each feature class in the version (there are 6 of them), each line followed by the text: "Bad connection handle".  These errors don't show up on redraw until after running the Python script with the SelectLayerByAttribute_managment function.

Any clues how I can fix these bad connection handles? I don't even know how to diagnose what the problem is.

:George Riner

Sonoma State University

5 Replies
PF1
by
Occasional Contributor II

I ran into this also today...

I have a pretty straight forward python script that uses arcpy.mapping.  The script just adds a few service layers, and vector (polygon) layers from a SQL Server 2012 enterprise GDB (EGDB).  These EGDB layers are registered as versioned.  All running v10.3.1 (desktop + EGDB).

I am directly interacting with the python interpreter window inside arcmap.

I've run this same code off and on over the past few days and it failed only once with over 100+ executions...

Any help or insight is greatly appreciated.  I am also using ​SelectLayerByAttribute_management

0 Kudos
JoeBryant2
Occasional Contributor II

Patrick,

I also have run into this error from time to time and have not been able to isolate the cause or fix.

Have you compressed the versioned database recently? I believe last time I had this issue ESRI support also recommended re-indexing the database.

Let us know what you find.

MicahBabinski
Occasional Contributor III

Hi George. That's frustrating! Have you installed the SQL Server native client on the computer in question? I remember having trouble connecting to SQLServer SDE in the past and I believe that fixed it. This ArcGIS Help page has some other things to check for when experiencing problems connecting to SQL Server with ArcGIS. It might be worth a look.

Good luck!

0 Kudos
DarylHochhalter
Occasional Contributor II

I am getting this error after using the popup menu to import multiple feature classes into an SQL geodatabase dataset from a file geodatabase. I have to close ArcCatalog and then the problem is gone until I import something else. ArcGIS for server 10.4, SQL 2014, on Windows Server 2012 R2

0 Kudos
WilliamCraft
MVP Regular Contributor

In the past, I have seen this error message occur when a connection was attempted with an older version of the SQL Server client communications software that is not supported.  

0 Kudos