当前位置:网站首页>ArcEngine secondary development based on C 57: the owner Sid on each user subscription does not exist

ArcEngine secondary development based on C 57: the owner Sid on each user subscription does not exist

2022-06-21 06:39:00 Xiao Xue leads the way

Problem description :

pFeatCursor = pFeatCls.Search(pQueryFilter, true); The following error appears :

Untreated System.Runtime.InteropServices.COMException

Message=" Everyone on a per user subscription SID non-existent ( Exception from HRESULT:0x80040207)"

Treatment scheme :

This exception occurs as long as it is caused by the filter WhereClause Caused by nonstandard statement , Solution :

  • Add a quote modifier to the field name ,"fieldName"
  • Add a single quote modifier to the value of the field ,"20010200LL00BS"
  • The modified query statement is : "\"fieldName\" = '20010200LL00BS'"

The revised code is as follows :

private void btnOk_Click(object sender, EventArgs e)
        {
            // Defining layers , Feature cursor , Query filter , elements 
            IFeatureLayer pFeatureLayer = this.axMapControl1.Map.get_Layer(cboLayer.SelectedIndex ) as IFeatureLayer;
            IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
            string strFldName = pFeatureClass.Fields.get_Field(cboField.SelectedIndex).Name; 
            IQueryFilter pQueryFilter = new QueryFilterClass();
            pQueryFilter.WhereClause = "strFldName='" + txtStateName.Text + "'";
            IFeatureCursor  pFeatureCursor = pFeatureLayer.Search(pQueryFilter, true);
            IFeature  pFeature = pFeatureCursor.NextFeature();
        }

Expand knowledge :

The inspection found that QueryFilter.WhereClause Statement in query shapefile There's a problem with the format layer , I'm trying to find out gdb The format of the layer will not report an error . open ArcGIS Comparing the two formats of attribute query, there are the following differences :

  1. shapefile Use double quotation marks for the field name of :"fieldName" and GDB Adoption of [fieldName] Format ;
  2. shapefile Fuzzy query with like '%A%' and GDB use like '*A*' ;
  3. shapefile The noncharacter field of does not support fuzzy queries and GDB Format support ; But I remember 9.2 It's like supporting ^_^.

Therefore, you must judge the data source type of the layer before querying :

 if (pDateset.Workspace.Type == esriWorkspaceType.esriFileSystemWorkspace)
{
    pQueryFilter.WhereClause = "\"" + fldName + "\"" + " like '%" + this.txt_findObject.Text.Trim() + "%'"; //shpfile
}
else
{
    pQueryFilter.WhereClause = "[" + fldName + "]" + " like '*" + this.txt_findObject.Text.Trim() + "*'"; //gdb
}

原网站

版权声明
本文为[Xiao Xue leads the way]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210627035934.html