I am writing a code in vb.net to delete features in a SDE FC listed in a FGDB FC. I am using a FC from a FGDB where I read all records. Then using the GLOBALID, the code searches for the matching record in SDE and then deletes it in SDE.
Please let me know if I need to open an editing session for this purpose and also if this code is the recommended code.
' ' Removes records from target feature ' ' Dim searchCur As IFeatureCursor = sourceFC.Search(Nothing, False) Dim featObj As IFeature = searchCur.NextFeature() Dim targetFields As IFields = targetFC.Fields ' Create a ComReleaser for cursor management. Using comReleaser As ESRI.ArcGIS.ADF.ComReleaser = New ESRI.ArcGIS.ADF.ComReleaser Dim targetQueryFilter As IQueryFilter = New QueryFilterClass() targetQueryFilter.SubFields = "GLOBALID" Dim targetCur As IFeatureCursor Dim targetFeature As IFeature Do While Not featObj Is Nothing targetQueryFilter.WhereClause = "GLOBALID = " & featObj.Value(featObj.Fields.FindField("GLOBALIDTXT")).ToString targetCur = targetFC.Search(targetQueryFilter, False) comReleaser.ManageLifetime(targetCur) targetFeature = targetCur.NextFeature If Not targetFeature Is Nothing Then targetFeature.Delete() End If featObj = searchCur.NextFeature() Loop End Using