So i update from 10.3.1 to 10.4.1 Because i got a new PC and i am updating some scripts and addin buttons. I have an addin button that updates points( personal SQL express database) based off of taxparcels. In 10.3.1 the addin works fine but now in 10.4.1 i am having issues. The only thing i changed was the name of the new workspace, the layer name stated the same. Not sure what's going on. Anyone have any ideas why it's not working in 10.4..1
Add-in Code:
arcpy.env.workspace = r"Database Servers\DSDGIS7WTALM_SQLEXPRESS.gds\TonyTwoWay (VERSION:dbo.DEFAULT)"
ptSelection = "TonyTwoWay.DBO.CCAP"
pointLayer = arcpy.env.workspace + os.sep + "TonyTwoWay.DBO.CCAP" #target point feature class
parcel = "TaxParcels1"
parcel_lyr = 'In_memory\parcel_lyr'
sjpoints = "In_memory\sjpoints"
poly = "ACCOUNT_1"
Pnt = "Account"
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
Error: I think it has to do with this line 4 "pointLayer = arcpy.env.workspace + os.sep + "TonyTwoWay.DBO.CCAP""
Traceback (most recent call last):
File "C:\Users\talmeida\AppData\Local\ESRI\Desktop10.4\AssemblyCache\{473AD3F3-86EE-417D-A6A9-13DFBB4B2150}\AddinToolsButtons_addin.py", line 295, in onClick
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 15779, in GetCount
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Rows: Dataset Database Servers\DSDGIS7WTALM_SQLEXPRESS.gds\TonyTwoWay (VERSION:dbo.DEFAULT)\TonyTwoWay.DBO.CCAP does not exist or is not supported
Failed to execute (GetCount).
is 'os' imported somewhere?
oh my bad, I have a few Add-ins and didn't want to post all of them:
I have two variables, one is running off the selection of the feature class rather than the entire feature class. If i don't have 'pointLayer = arcpy.env.workspace + os.sep + "TonyTwoWay.DBO.CCAP"' i will have an empty list i believe.
if i change line pointLayer = arcpy.env.workspace + os.sep + "TonyTwoWay.DBO.CCAP" to just ptSelection = "TonyTwoWay.DBO.CCAP" i get error:
AddinToolsButtons_addin.py", line 344, in onClick
AddressID = point_list[-1] + 1
IndexError: list index out of range
I tried the full path 'C:\\Users\\username\\AppData\\Roaming\\ESRI\\Desktop10.4\\ArcCatalog\\' but no luck.
Add-in:
arcpy.env.workspace = r"Database Servers\DSDGIS7WTALM_SQLEXPRESS.gds\TonyTwoWay (VERSION:dbo.DEFAULT)"
ptSelection = "TonyTwoWay.DBO.CCAP"
pointLayer = arcpy.env.workspace + os.sep + "TonyTwoWay.DBO.CCAP" #target point feature class
parcel = "TaxParcels1"
parcel_lyr = 'In_memory\parcel_lyr'
sjpoints = "In_memory\sjpoints"
poly = "ACCOUNT_1"
Pnt = "Account"
ptCount = int(arcpy.GetCount_management(pointLayer).getOutput(0))
After a days long of search i found a thread that indicated "Database Server connection to a SDE database using SQLexpress is not appropriate for editing data, only for administering it (i.e. permissions, etc.) You must connect to the same database using the Database Connections node in ArcGIS, and use that connection for editing purposes, using the appropriate Database Connection as the output workspace."
So i created a Database Servers node in the Catalog to the sql express data base in ArcCatalog.
I changed this line:
'arcpy.env.workspace = r"Database Servers\DSDGIS7WTALM_SQLEXPRESS.gds\TonyTwoWay (VERSION:dbo.DEFAULT)"'
To
arcpy.env.workspace = r"Database Connections\Connection to DSDGIS7WTALM_sqlexpress.sde"
After adding/change the connection i was able to get the addin to work. Not why i doesn't work in 10.4.1 but it worked fine in 10.3.1, maybe it's just me.
Resource.
Database server connections—Help | ArcGIS for Desktop