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.

I have a command button in ArcMap, this command button working to add a new field to a specific table in ArcCatalog.

e.g. i have a table contains many fields like ObjectID , FeatureName, ... i want to add a new field programmatically while ArcMap is running .

Is there anyway to add a new field to ArcCatalog while the ArcMap is running.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

This the solution :

ITable woTable ;
            ISchemaLock schemaLock = (ISchemaLock)woTable;
            IField newField = this.WOAttributeProperties.getOrSetField;
            try
            {
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
                woTable.AddField(newField);
            }
            catch (Exception exc)
            {
                System.Diagnostics.Debug.WriteLine("An Error Occured: " + exc.Message);
            }
            finally
            {
                // Set the lock to shared, whether or not an error occurred.
                schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
            }
share|improve this answer
add comment

I'm not sure what you mean by "add a new field to ArcCatalog" but from ArcMap you could just locate (best to use Search window in ArcGIS 10 or ArcToolbox previously) the Add Field tool and run it to add a new field.

share|improve this answer
    
i already have a table, contains many fields e.g. OBJECTID , FeatureName, ... i want to add a new field programmatically, i know that you can't add a new field to ArcCatalog While ArcMap running, i am asking if there is anyway to add a new field to ArcCatalog while ArcMap is running. hope it's clear now. Regards –  RASHOMON Jul 26 '12 at 9:55
    
I very rarely use ArcCatalog since the release of 10.0 - is there a reason why you have to do this in ArcCatalog rather than from ArcMap (or a standalone program) with ArcCatalog closed? –  PolyGeo Jul 26 '12 at 10:18
    
i had to do it in ArcCatalog. if i create a new desktop program, i guess it will be working fine, but i prefer to do it in a command button in the ArcMap. and thanks for your replying. –  RASHOMON Jul 26 '12 at 10:33
    
@SWAIS: Every toolbox and tool in ArcCatalog is also available in ArcMap. –  mhoran_psprep Jul 26 '12 at 12:55
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.