Hello everyone,
This is my current configuration:
ArcGIS 10.4
VS 2015
I am trying to run a SQL Query inside a Console Application to find records that are duplicated.
The application fails with this error message: The path could not be found. (Exception from HRESULT: 0x80030003 (STG_E_PATHNOTFOUND))
When it reaches this line: Using comReleaser As ComReleaser = New ComReleaser()
Dim queryBuilder As StringBuilder = New StringBuilder()
queryBuilder.Append("SELECT CONTENTID, COUNT(CONTENTID) AS Counter ")
queryBuilder.Append("FROM table ")
queryBuilder.Append("GROUP BY CONTENTID ")
queryBuilder.Append("HAVING(COUNT(CONTENTID) > 1) ")
queryBuilder.Append("ORDER BY Counter DESC")
Dim query As String = queryBuilder.ToString()
..........
Using comReleaser As ComReleaser = New ComReleaser()
Finally I used Select by Attribute following this link to select all the duplicated records, and export the in a new FC.
This is the code:
Dim pMakeFetureLayerSelectByAttributes As MakeFeatureLayer
pMakeFetureLayerSelectByAttributes = New MakeFeatureLayer()
' Set the OverwriteOutput setting to True
GP.OverwriteOutput = True
' Process: Make Feature Layer...
pMakeFetureLayerSelectByAttributes.in_features = pFeatureClass
pMakeFetureLayerSelectByAttributes.out_layer = "Duplicates_Layer"
pMakeFetureLayerSelectByAttributes.field_info = " ...... "
RunTool(GP, pMakeFetureLayerSelectByAttributes, Nothing)
Dim pSelectByAttribute As SelectLayerByAttribute
pSelectByAttribute = New SelectLayerByAttribute()
pSelectByAttribute.in_layer_or_view = "Duplicates_Layer"
pSelectByAttribute.selection_type = "NEW_SELECTION"
pSelectByAttribute.where_clause = "CONTENTID In (SELECT [CONTENTID] FROM [mytable] GROUP BY [CONTENTID] HAVING Count(*)>1 )"
RunTool(GP, pSelectByAttribute, Nothing)
Dim pCopyFeatures As CopyFeatures
pCopyFeatures = New CopyFeatures()
pCopyFeatures.in_features = "Duplicates_Layer"
pCopyFeatures.out_feature_class = pfeatureDuplicate
RunTool(GP, pCopyFeatures, Nothing)