Skip to content

Instantly share code, notes, and snippets.

@BrunoCaimar
Created September 27, 2019 20:09
Show Gist options
  • Save BrunoCaimar/5f8be14b9106090fb2db8380aed13a0c to your computer and use it in GitHub Desktop.
Save BrunoCaimar/5f8be14b9106090fb2db8380aed13a0c to your computer and use it in GitHub Desktop.
Adiciona novo campo, via AO, em tabela registrada
private static void AdicionarCampo(IWorkspace workspace)
{
var table2AddField = ((IFeatureWorkspace)workspace).OpenTable("TESTE_A");
var schemaLock = (ISchemaLock)table2AddField;
try
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
var newField = new FieldClass();
var field = (IFieldEdit2)newField;
field.Name_2 = "NovoCampo";
field.Type_2 = esriFieldType.esriFieldTypeString;
field.Length_2 = 50;
field.DefaultValue_2 = "Teste";
table2AddField.AddField(newField);
}
finally
{
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment