You are here: > ESRI Forums > arcgis engine forums > Thread Replies

ArcGIS Engine Forums

ArcGIS Engine: ArcObjects .NET API forum

Error ERROR 000728 on CalculateField after...   Randal Greene Jul 17, 2009
Re: Error ERROR 000728 on CalculateField af...   Reena Bhatt Jul 17, 2009
Re: Error ERROR 000728 on CalculateField af...   Randal Greene Jul 18, 2009
Re: Error ERROR 000728 on CalculateField af...   Reena Bhatt Jul 19, 2009
Re: Error ERROR 000728 on CalculateField af...   Randal Greene Jul 20, 2009
Re: Error ERROR 000728 on CalculateField af...   Reena Bhatt Jul 22, 2009
Re: Error ERROR 000728 on CalculateField af...   Randal Greene Jul 22, 2009
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Randal Greene 
Date Jul 17, 2009 
Message I'm building a custom GeoProcessing tool for 9.3 using VS.NET 2008 (C#).

When I add a field to a FeatureClass, then attempt to calculate the field using the CalculateField tool, it returns "ERROR 000728: Field COCALC does not exist within table". Inspecting the FeatureClass afterwards shows that the field was in fact added!

This is true whether I add the field using the AddField tool or IFeatureClass.AddField, and whether I obtain a schema lock. This works fine in a Python script tool using AddField_management followed by CalculateField_management.

I know the CalculateField code is valid, because it works if the field exists before the tool is run.

Where might the problem lie?

Thanks in advance,
Randal 
 
public void Execute(IArray paramvalues, ITrackCancel trackcancel, IGPEnvironmentManager envMgr, IGPMessages message)
{
	Geoprocessor gp = new Geoprocessor();

	IGPValue inputPolygonFeatureClass = m_GPUtilities.UnpackGPValue(paramvalues.get_Element(0));
	IFeatureClass featureClass;
	IQueryFilter qf;
	m_GPUtilities.DecodeFeatureLayer(inputPolygonFeatureClass, out featureClass, out qf);
	ISchemaLock schemaLock = (ISchemaLock)featureClass;

	IFieldEdit newField = new FieldClass();
	newField.Type_2 = esriFieldType.esriFieldTypeInteger;
	newField.Name_2 = "COCALC";
	schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
	featureClass.AddField(newField);
	schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);

	// Execute in this block fails with error "ERROR 000728: Field COCALC does not exist within table"
	CalculateField calculateFieldTool = new CalculateField();
	calculateFieldTool.in_table = inputPolygonFeatureClass;
	calculateFieldTool.field = "COCALC";
	calculateFieldTool.expression_type = "VB";
	calculateFieldTool.expression = "x";
	calculateFieldTool.code_block = "x = 1";
	schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);
	gp.Execute(calculateFieldTool, trackcancel);
	schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
}
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Reena Bhatt 
Date Jul 17, 2009 
Message Am sure you would have taken care but is there any datatype mismatch? As you are trying to comapare with numeric value and still its in qoutes. 
  ~Reena  
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Randal Greene 
Date Jul 18, 2009 
Message Thanks for the idea Reena, but the CalculateField code block works fine if the field exists before the routine is run. It's something to do with adding then immediately calculating the field...

Randal 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Reena Bhatt 
Date Jul 19, 2009 
Message Try adding buffer time like do:events in Visual Basic. Also clear your feature class and set it again before calculatefiled block. 
  ~Reena  
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Randal Greene 
Date Jul 20, 2009 
Message Thanks again Reena, but still no luck! After adding the field, I set featureClass = null, re-ran UnpackGPValue and reran DecodeFeatureLayer.

Any other thoughts on how I should close/re-open the featureClass or other things to try?

Randal 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Reena Bhatt 
Date Jul 22, 2009 
Message Ok just for a chance , use IField interface to check programatically if the field exits. It will return -1 is it does not exits.

 
  ~Reena  
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Error ERROR 000728 on CalculateField after AddField in custom .NET tool 
Author Randal Greene 
Date Jul 22, 2009 
Message Well done Rheena!

Apparently checking for the field is sufficient to cause a refresh of the object.

Thanks again,
Randal