AddField(pTable, "Name", "Text", , , 254) Public Sub AddField(ByVal Input As Object, ByVal FieldName As String, ByVal FieldType As String, Optional ByVal Precision As Long = 0, Optional ByVal Scale As Long = 0, Optional ByVal Length As Long = 0, Optional ByVal FieldAlias As String = Nothing, Optional ByVal Nullable As String = "NULLABLE", Optional ByVal Required As String = "NON_REQUIRED", Optional ByVal Domain As String = Nothing) Dim AddField As New ESRI.ArcGIS.DataManagementTools.AddField Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 Try Using releaser As New ESRI.ArcGIS.ADF.ComReleaser releaser.ManageLifetime(AddField) AddField.in_table = Input AddField.field_name = FieldName AddField.field_type = FieldType AddField.field_precision = Precision AddField.field_scale = Scale AddField.field_length = Length AddField.field_alias = FieldAlias AddField.field_is_nullable = Nullable AddField.field_is_required = Required AddField.field_domain = Domain Result = RunTool(AddField, Nothing) If Result Is Nothing Then System.Windows.Forms.MessageBox.Show("Could not add field") End If End Using Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "Add Field error") End Try End Sub Friend Function RunTool(ByVal Process As ESRI.ArcGIS.Geoprocessor.IGPProcess, ByVal TC As ESRI.ArcGIS.esriSystem.ITrackCancel2) As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2 Try Result = CType(Globals.GP.Execute(Process, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2) If Result.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then ReturnMessages(Result, "Geoprocessing Error") Globals.GP.ClearMessages() Catch ex As Exception ReturnMessages(Result, "Fail") System.Windows.Forms.MessageBox.Show(ex.ToString, "Run Geoprocessor") End Try Return Result End Function Private Sub ReturnMessages(ByVal pResult As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2, ByVal Title As String) Dim ErrorMessage As String If pResult.MessageCount > 0 Then For Count As Integer = 0 To pResult.MessageCount - 1 ErrorMessage += pResult.GetMessage(Count) Next End If System.Windows.Forms.MessageBox.Show(ErrorMessage, Title) End Sub
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.