Quantcast
Channel: Forums - ArcObjects SDKs
Viewing all articles
Browse latest Browse all 1374

update atribut

$
0
0
Hi,

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
Try
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)
agc.Connect()
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
ft.Store()
r = "success"
Else
r = "error: field not found."
End If

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

Else
r = "error: data not found."
End If
sc.ReleaseContext()
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

Viewing all articles
Browse latest Browse all 1374