Select to view content in your preferred language

Update the shape file using the table

674
2
12-13-2010 08:44 AM
SanthoshBalakrishnapillai
Deactivated User
If anyone can help me out with this problem.It works for the first record and hangs forever. Please correct me to solve this problem.I am trying to update the shape file using the table.

Dim pMxdoc As IMxDocument
Set pMxdoc = ThisDocument

Dim pMap As IMap
Set pMap = pMxdoc.FocusMap

Dim pFlayer As IFeatureLayer
Dim pFClass As IFeatureClass

Set pFlayer = pMxdoc.FocusMap.Layer(1)
Set pFClass = pFlayer.FeatureClass

Dim pFields As IFields
Set pFields = pFClass.Fields

Dim pFCursor As IFeatureCursor
Set pFCursor = pFClass.Update(Nothing, True)

Dim pFeature As IFeature
Set pFeature = pFCursor.NextFeature

Dim intMunl As Integer
intMunl = pFCursor.FindField("MUNL")

Dim intCityl As Integer
intCityl = pFCursor.FindField("CITY_L")


Dim pFact As IWorkspaceFactory
Set pFact = New AccessWorkspaceFactory

Dim pWorkspace As IWorkspace
Set pWorkspace = pFact.OpenFromFile("E:\\County_MUN\County.mdb", 0)

Dim pFeatureWorkspace As IFeatureWorkspace
Set pFeatureWorkspace = pWorkspace

Dim pTable As ITable
Set pTable = pFeatureWorkspace.OpenTable("suffolk_mun")


Dim pTCursor As ICursor
Set pTCursor = pTable.Search(Nothing, True)

Dim pRow As IRow
Set pRow = pTCursor.NextRow

Do Until pFeature Is Nothing


        If pFeature.Value(intMunl) = pRow.Value(1) Then
            pFeature.Value(intCityl) = pRow.Value(2)
            pFCursor.UpdateFeature pFeature
            Set pFeature = pFCursor.NextFeature
        End If

   
Loop

Thanks
Santhosh
0 Kudos
2 Replies
FrankKish
Esri Contributor
I did not look at most of your code but I suspect that the "Set pFeature = pFCursor.NextFeature" should not be in the if block as you have it, otherwise you are not going to the NextFeature unless you go into the if block.

So something like this....

If pFeature.Value(intMunl) = pRow.Value(1) Then
    pFeature.Value(intCityl) = pRow.Value(2)
    pFCursor.UpdateFeature pFeature
End If

Set pFeature = pFCursor.NextFeature
0 Kudos
SanthoshBalakrishnapillai
Deactivated User
My problem is that prow.value(1) is not on a loop. So I put it in the loop.

Do until pfeature is nothing
do until prow is nothing
    If pFeature.Value(intMunl) = pRow.Value(1) Then
     pFeature.Value(intCityl) = pRow.Value(2)
     pFCursor.UpdateFeature pFeature
    end if
  set prow=ptcursor.nextrow
loop

Set pFeature = pFCursor.NextFeature


Loop

But on this the second loop is not going back for every feature. How can I do that. Please help.
0 Kudos