Unlocking a FeatureClass after edits

2355
3
Jump to solution
06-12-2012 06:32 AM
SachaTousignant
New Contributor III
Hello everyone,

I'm trying to see if it's possible to unlock my FeatureClass after I added some features or modified some.



Here's some of the main lines :
IFeatureBuffer featureBuffer = infosXML.FeatureclassSitesReference.CreateFeatureBuffer(); IFeatureCursor cursorReferenceInsert = infosXML.FeatureclassSitesReference.Insert(true); featureBuffer.Shape = siteCourant.ShapeCopy; cursorReferenceInsert.InsertFeature(featureBuffer); cursorReferenceInsert.Flush();


Right now after doing this code, it locks the table from the others users.


EDIT :: It seems to be locked only when adding new features by either the way with FeatureBuffer + FeatureCursor or with FeatureClass.createFeature()
When modifying existing features and storing the changes, it doesn't lock the table.
0 Kudos
1 Solution

Accepted Solutions
ThavitinaiduGulivindala
Occasional Contributor
try releasing

featureBuffer and cursorReferenceInsert objects
e.g. in .Net, we can write Marshal.ReleaseComObject(
cursorReferenceInsert)

View solution in original post

0 Kudos
3 Replies
ThavitinaiduGulivindala
Occasional Contributor
try releasing

featureBuffer and cursorReferenceInsert objects
e.g. in .Net, we can write Marshal.ReleaseComObject(
cursorReferenceInsert)

View solution in original post

0 Kudos
SachaTousignant
New Contributor III
try releasing

featureBuffer and cursorReferenceInsert objects
e.g. in .Net, we can write Marshal.ReleaseComObject(
cursorReferenceInsert)



Tyvm, I didn't know about it, I'll def try it out.

Worked out, thx alot! +1
0 Kudos
DuncanHornby
MVP Frequent Contributor
Another way to release cursors is using the USING statement and ComReleaser. See the VB code below


' For ArcGIS 10 using VS 2010 you need to import the following
Imports ESRI.ArcGIS.ADF.Connection.Local
Imports ESRI.ArcGIS.ADF
Dim pQueryFilter As IQueryFilter
pQueryFilter= New QueryFilterClass
pQueryFilter.WhereClause = "ID = 1"
Using releaser As New ComReleaser
    Dim pFeatureCursor As IFeatureCursor
    pFeatureCursor = pFeatureclass.Update(pQueryFilter, True)
    releaser.ManageLifetime(pFeatureCursor)
    Dim pFeature As IFeature 
    pFeature = pFeatureCursor.NextFeature
    While pFeature IsNot Nothing
        ' Do something with pFeature
        pFeatureCursor.UpdateFeature(pFeature)
        pFeature = pFeatureCursor.NextFeature
     End While
End Using

Duncan
0 Kudos