Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Can an ODBC Oracle table attached by OLE within ArcMap be edited/updated by using ArcObjects? If so, what are the procedural steps for doing this? Are there code examples out there showing how to do this?

Thank You

share|improve this question
1  
Why not just use ODP.net instead? –  Kirk Kuykendall Nov 17 '11 at 3:18
1  
I'm not sure why you'd want to use ArcObjects to do that. Wouldn't it be more efficient to edit it using SQL through OLEDB? –  Bill Dollins Nov 17 '11 at 11:29
add comment

1 Answer

I can understand why you would like to use ArcObjects instead of ADO to update or read the business tables.

When ArcMap connects to your Geodatabase, it establishes a dedicated connection called a Workspace. It seems like a waste of memory and resources to establish another connection via ADO to your geodatabase while you have an existing connection which you can use. This is especially valid when you have multiple users, spawning two connections for each user can seem inefficient.

To update or read your table from ArcMap you have to get hold of the workspace somehow. This easy way is to get it from the first layer. Following code is in VB.NET

Dim pWorkspace as IWorkspace
Dim pMxdoc as ImxDocument = application.document ' get the arcmap document
Dim pFLayer as IFeatureLayer = pMxdoc.FocusMap.Layers(0)
Dim pDS as IDataset = pFLayer.FeatureClass
pWorkspace = pDs.Workspace 

now that we have the workspace you can use it to open your table by name, and update the name field of record having object id 1235

Dim pFWorkspace As IFeatureWorkspace
Dim pTable As ITable = pFWorkspace.OpenTable("mytablename")

'start editing
Dim pEWorkspace As IWorkspaceEdit = pWorkspace
pEWorkspace.StartEditing(False)
pEWorkspace.StartEditOperation()

Dim pRow As IRow = pTable.GetRow(1235) 'get particular Row to update
pRow.Value(pRow.Fields.FindField("NAME")) = "A NEW NAME"
pRow.Store()

pEWorkspace.StopEditOperation()
pEWorkspace.StopEditing(True)
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.