I'm attempting to move a point and have the attached line features move with it. It works the first time, bt the second time I get the error {"The database engine could not lock table 'DELTA_SanitaryLines_SHAPE_Index' because it is already in use by another person or process."} I guess something I'm leaving something open programmatically as the database isn't physically open anywhere and I'm the only user/programmer on the project. This is the line it doesn't like:
'Get and move attached sanlines ' We have to look for Sanlines that come into the manhole and also sanlines that leave from the manhole ' We will do this as two separate While loops 'Find San Lines with matching GfkMHto IDs sanlineQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilter sanlineQueryFilter.WhereClause = "([GFKmhTo] = " & movedManholeGID & ") OR ([GFKmhFrom] = " & movedManholeGID & ")"
Dim sanlineFeatureCursor As IFeatureCursor = Nothing sanlineFeatureCursor = sanlineFeatClass.Update(sanlineQueryFilter, False) sanlineFeature = sanlineFeatureCursor.NextFeature
'Move sanline ToPoint to match location of moved manhole While Not sanlineFeature Is Nothing pLine = sanlineFeature.Shape sanlineGfkMHfromVal = sanlineFeature.Value(sanlineGfkMHfromFld) If sanlineGfkMHfromVal = movedManholeGID Then pLine.ToPoint = movedPoint Else pLine.FromPoint = movedPoint End If lengthsanline = pLine.Length sanlineFeature.Shape = pLine
Anytime you use an ArcObjects cursor (ICursor or IFeatureCursor), you need to release the reference as soon as you're done with it by calling Marshal.FinalReleaseComObject. The same is true for any IFeature/IRow objects you're using. If you're using IFeature/IRow objects within a loop, then call FinalReleaseComObject on them before setting the feature/row variable to the next object in the cursor. You can also use ESRI's ComReleaser class.
Doing this should release any locks on the database.
Anytime you use an ArcObjects cursor (ICursor or IFeatureCursor), you need to release the reference as soon as you're done with it by calling Marshal.FinalReleaseComObject. The same is true for any IFeature/IRow objects you're using. If you're using IFeature/IRow objects within a loop, then call FinalReleaseComObject on them before setting the feature/row variable to the next object in the cursor. You can also use ESRI's ComReleaser class.
Doing this should release any locks on the database.