在AO中批量增加字段(VB.NET):
<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>
Private Sub create_Field(ByVal featureClass As IFeatureClass, ByVal name As String)
Try
Dim field As IField = New FieldClass()
Dim fieldEdit As IFieldEdit = CType(field, IFieldEdit)
fieldEdit.Precision_2 = 6
fieldEdit.Scale_2 = 2
fieldEdit.Name_2 = name
fieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble
AddFieldToFeatureClass(featureClass, fieldEdit)
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Public Sub AddFieldToFeatureClass(ByVal featureClass As IFeatureClass, ByVal field As IField)
Dim schemaLock As ISchemaLock = CType(featureClass, ISchemaLock)
Try
' A try block is necessary, as an exclusive lock may not be available.
schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock)
' Add the field.
featureClass.AddField(field)
Catch exc As Exception
' Handle this in a way appropriate to your application.
Console.WriteLine(exc.Message)
Finally
' Set the lock to shared, whether or not an error occurred.
schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock)
End Try
End Sub
调用:
Dim i As Int16
For i = 1 To 96
create_Field(pFeatcls, "F_" + String.Concat(i))
Next
<script type="text/javascript"> </script> <script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script>