Fields

854
3
03-01-2011 11:44 PM
sujaygarapati
New Contributor
Hi i am trying to add field using GP in Arcengine  but i am unable to add can anyone help me out of this below is the code i am  struggling with,thanks in advance

Private Sub pAField_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pAField.Click

        Dim pinput As String = TextBox1.Text
        TextBox1.Text = pinput
        Dim pname As String = TextBox2.Text
        TextBox2.Text = pname
        Dim palias As String = TextBox3.Text
        TextBox3.Text = palias
        Dim ptype As String = ComboBox1.Text
        ComboBox1.Text = ptype

        Dim plength As Integer = Convert.ToInt32(TextBox4.Text)

        Dim pFScale As String = Convert.ToInt32(TextBox5.Text)

        Dim pPrecsion As String = Convert.ToInt32(TextBox6.Text)


        Dim Pfield As New AddField(pinput, pname, ptype)
        With Pfield
            .field_alias = palias
            '.field_type = ComboBox1.SelectedText.ToString
            .field_length = plength
            .field_scale = pFScale
            'field_precision = pPrecsion
        End With
        Dim GP As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor()
        GP.Execute(Pfield, Nothing)
        MessageBox.Show("Completed")


    End Sub
0 Kudos
3 Replies
NeilClemmons
Regular Contributor III
Most, if not all, of the geoprocessor tool classes take references to the actual objects you're operating on instead of text strings.  In your case, you're passing in a text string for the input object class.  You need to be passing in the actual feature class or table.  Also, I'm not sure I'd bother with all of the overhead of using the geoprocessing environment just to add a field to an object class.  Just create the new field and call the AddField method on the table or feature class.
0 Kudos
KenBuja
MVP Esteemed Contributor
You can pass either a string of the full name of the input object class (C:\Data\table.dbf or C:\Data\test.gdb\testtable) to a geoprocessing tool or a reference to the actual object, but you can't just send the name without the path (table.dbf or testtable). In one tool, CreateFeatureClass, there is a bug (NIM006068) where the template property cannot accept a reference (IDataset::FullName), but will only accept a string of the full path and name of the feature class.

Have you examined the results of running the geoprocessing tool (found under the Geoprocessing|Results in the main menu)? Even for processing running in scripts, it will report any errors that may occur and you can figure out what is going wrong with your code. The attached image shows the results of a test application using the geoprocessor.
0 Kudos
sujaygarapati
New Contributor
Thank u very much problem was solved
0 Kudos