update atribut

Discussion created by haniu_ntt on Apr 19, 2013
Latest reply on Apr 23, 2013 by haniu_ntt

I found a code like this:

==start code=============
  Public Function InsertPoint(ByVal name As String, ByVal x As Double, ByVal y As Double, ByVal fld As String, ByVal fldval As String) As String
        Dim sc As IServerContext = Nothing
        Dim r As String
            Dim idt As ESRI.ArcGIS.ADF.Identity = New ESRI.ArcGIS.ADF.Identity("username", "password", "domain")
            Dim agc As ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection = New ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection("server", idt)
            Dim sm As IServerObjectManager = agc.ServerObjectManager
            sc = sm.CreateServerContext("basemap", "MapServer")
            Dim so As IServerObject = sc.ServerObject
            Dim prop As IPropertySet = sc.CreateObject("esriSystem.PropertySet")

            'connect to db
            prop.SetProperty("SERVER", "svr-955")
            prop.SetProperty("INSTANCE", "esri_sde")
            prop.SetProperty("DATABASE", "reg_opt")
            prop.SetProperty("USER", "sde")
            prop.SetProperty("PASSWORD", "sde")
            prop.SetProperty("VERSION", "sde.DEFAULT")
            'prop.SetProperty("VERSION", "SDE.test")

            Dim wsf As IWorkspaceFactory = sc.CreateObject("esriDataSourcesGDB.SdeWorkspaceFactory")
            Dim fws As IFeatureWorkspace = wsf.Open(prop, 0)
            Dim fc As IFeatureClass = fws.OpenFeatureClass(name)

            If Not fc Is Nothing Then
                If fc.ShapeType = esriGeometryType.esriGeometryMultipoint Or fc.ShapeType = esriGeometryType.esriGeometryPoint Then
                    Dim i As Integer = fc.FindField(fld)

                    'insert new object
                    If i > -1 Then
                        Dim frc As IFeatureCursor = fc.Insert(False)
                        Dim ft As IFeature = fc.CreateFeature()
                        Dim pnt As IPoint = sc.CreateObject("esriGeometry.Point")
                        pnt.X = x
                        pnt.Y = y
                        ft.Value(i) = fldval
                        ft.Shape = pnt
                        r = "success"
                        r = "error: field not found."
                    End If

                    r = "error: data not point."
                End If

                r = "error: data not found."
            End If
        Catch ex As Exception
            r = "error:" & ex.Message
        End Try
        Return r
    End Function

==end code=============

I want to replace the "insert new object" with "update existing object"

How can i achieve that ?

many many thanks