ArcObjects Library Reference  (GeoDatabase)    

IClass.AddField Method

Adds a field to this object class.

[Visual Basic 6.0]
Sub AddField(
    ByVal Field As IField _
)
[Visual Basic .NET]
Public Sub AddField ( _
    ByVal Field As IField _
)
[C#]
public void AddField (
    IField Field
);
[Java]
public void addField (
    IField Field
)
throws
    IOException,
    AutomationException
[C++]
HRESULT AddField(
  IField* Field
);
[C++]

Parameters

Field [in]

  Field is a parameter of type IField

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Errors Returned

-2147220649 - FDO_E_TABLE_DUPLICATE_COLUMN

A field with the specified name already exists in the table.

-2147220961 - FDO_E_NO_SCHEMA_LICENSE

You are not licensed to modify the schema of the feature class.  This error can arise with an ArcView license when a field is added to a feature class that participates in a geometric network, topology or composite relationship class (such as feature-linked annotation)

Functional License Check

If your application/site is not appropriately licensed, AddField can return an Err.Number of FDO_E_NO_SCHEMA_LICENSE.

Remarks

Prior to adding a new field to a class, an exclusive schema lock should be obtained using the ISchemaLock interface.

Attempting to add a new field that does not allow null values will fail, if the class already has data in it. The only solution is to recreate the class with the non-nullable field, then copy the rows from the original class into the new class.

See Also

IClass Interface