vb.net arcobjects strange when using feature store

2167
6
Jump to solution
10-19-2014 09:35 PM
LiYao
by
New Contributor III

Dear all,

I met a strange thing when I am trying to update value in attribute table. I am in editing session and after I perform feature.store and open the attribute table, there is no record in the attribute table. When I exit editing session, the records return, but the value not updated.

My code is as follows:

        pActiveView = pMxDoc.FocusMap

        pMxDoc = My.ArcMap.Application.Document

        pMap = pMxDoc.FocusMap

        Dim layerNum = GetIndexNumberFromLayerName(pActiveView, "proj_db.DBO.Line")

        Dim pFLayer As IFeatureLayer

        pFLayer = pMap.Layer(layerNum)

        Dim featureClass As ESRI.ArcGIS.Geodatabase.IFeatureClass = pFLayer.FeatureClass

        If featureClass is DbNull.value then

              Return

        End If

        Dim feature as IFeature = pFLayer.FeatureClass.GetFeature(maxOBJECID)

        If feature is DbNull.value then

          Return

        End If

        Dim nameFieldIndex As Integer = pFLayer.FindField("Seg_ID")

        feature.Value(nameFieldIndex) = inputSegID

        feature.Store()

There no error also. Don't know what is up in my code, please help me on it, thank you very much!

I am using arcobjects 10.2.2.

0 Kudos
1 Solution

Accepted Solutions
DuncanHornby
MVP Notable Contributor

OK the only thing I can think of is export the data to a file geodatabase, adjust the code accordingly and see if it executes with error. If that happens then it would suggest your code is OK and it is some sort of problem with the other database (I guess it is ArcServer)? At that point I'm out of ideas as I don't use enterprise databases.

View solution in original post

0 Kudos
6 Replies
DuncanHornby
MVP Notable Contributor

I don't know if this is the problem but I would not have used DbNull.value. I would use Nothing.

So my line would be:

If featureClass is Nothing Then

:

Same when you test feature.

0 Kudos
LiYao
by
New Contributor III

Hi Duncan,

Thank you very much for the reply. But after I modify the code, the result still the same.

The problem is caused by the line feature.store().

Is there errors other than the DBNull? Thanks.

0 Kudos
DuncanHornby
MVP Notable Contributor

Is nameFieldIndex definitely getting set to the correct index position? If you have joins on the table then I believe you will need to prefix it with the table name.

0 Kudos
LiYao
by
New Contributor III

Hi Duncan,

Thanks a lot for the answer. After I add the table name before the field name, it still not work.

If I use:

Dim nameFieldIndex As Integer = pFLayer.FindField("proj_db.DBO.Line.Seg_ID")

Then the application will exit.

If I use:

Dim nameFieldIndex As Integer = pFLayer.FeatureClass.FindField("proj_db.DBO.Line.Seg_ID")

It will still the strange result as described in the question.

Totally no idea on it.....

0 Kudos
DuncanHornby
MVP Notable Contributor

OK the only thing I can think of is export the data to a file geodatabase, adjust the code accordingly and see if it executes with error. If that happens then it would suggest your code is OK and it is some sort of problem with the other database (I guess it is ArcServer)? At that point I'm out of ideas as I don't use enterprise databases.

0 Kudos
LiYao
by
New Contributor III

Hi Duncan,

Thank you so much for the kind help. I will look further according to your suggestion.

0 Kudos