Xhosa

Problem adding multiple fields when creating new featureClass

Discussion created by Xhosa on Mar 3, 2014
Latest reply on Mar 3, 2014 by Neil
I am trying to create a new featurclass in an existing GDB that creates multiple fields and populates the field with data pulled from an sql query. I am able to add 1 field and populate it with the corresponding data from my query but when I add a 2nd field I run into an error that says 'The name of the Field is invalid: valid names may contain letters, numbers or underscores.'
My question is a)am I missing something/setting up the featureClass wrong? b)Do I need to open an editing session?
I am using the code below:

//Create fields
            IField nameField = new FieldClass();
            IFieldEdit nameFieldEdit = (IFieldEdit)nameField;
            nameFieldEdit.Name_2 = "Name";
            nameFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
            nameFieldEdit.Length_2 = 100;
            fieldsEdit.AddField(nameField);


            nameField = new FieldClass();
            nameFieldEdit.Name_2 = "Lat";
            nameFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
            nameFieldEdit.Length_2 = 10;
            fieldsEdit.AddField(nameField);

            FieldChecker fieldChecker = new FieldCheckerClass();
            IEnumFieldError enumFieldError = null;
            IFields validatedFields = null;
            fieldChecker.ValidateWorkspace = (IWorkspace)fws;
            fieldChecker.Validate(fields, out enumFieldError, out validatedFields);


            //Create the featureClass!
            MessageBox.Show("Here?");
            IFeatureClass featureClass = fws.CreateFeatureClass(fcName, validatedFields, null, null , esriFeatureType.esriFTSimple, "Shape", "");

Any help is greatly appreciated!

Outcomes