Public IFeatureCursor QueryFeaturesCursor (IWorkspace ws, string featclsName, long GB)
{
// Interface QI to IFeatureWorkspace
IFeatureWorkspace pFeatWorkspace;
PFeatWorkspace = ws as IFeatureWorkspace;
IFeatureClass pFeatcls;
PFeatcls = pFeatWorkspace. OpenFeatureClass (featclsName );
IQueryFilter pQueryFilter;
PQueryFilter = new QueryFilterClass ();
PQueryFilter. WhereClause = "GB =" + GB. ToString ();
// PQueryFilter. WhereClause = "GB = 230102 ";
IFeatureCursor pFeatCur;
PFeatCur = pFeatcls. Update (pQueryFilter, false );
Return pFeatCur;
}
This code is used to select the GB code as the layer element of the specified parameter. However, if the specified layer does not have the GB field, the parameter is insufficient. expected to be 1. The solution is to determine whether the GB field exists before referencing it. Without this field, the above Code will not be executed.