您的位置:首页 > 编程语言 > C#

AE+C#开发问题实录(一)每用户订阅上的所有人 SID 不存在

2015-06-24 10:50 344 查看
最近做“GIS软件开发”的课程设计时,想要实现按属性字段进行查询,并将查询结果高亮显示时,程序运行后遇到了如下问题:

在 pFeatCursor = pFeatCls.Search(pQueryFilter, true) 这行代码报错,提示错误信息为:

“System.Runtime.InteropServices.COMException”类型的未经处理的异常在 EX4_1.exe 中发生 。

其他信息: 每用户订阅上的所有者 SID 不存在 (异常来自 HRESULT:0x80040207)

查阅了几篇博文之后发现,问题出在设置查询过滤条件这句话中:
pQueryFilter.WhereClause = cb_field.Text + "=" + listBox1.SelectedItem.ToString();
<span style="text-indent: 28px; font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">使用的数据是shp格式,查询语句在书写时需要加上双引号:</span><pre name="code" class="csharp">pQueryFilter.WhereClause = "" + cb_field.Text  + "" + "= " + listBox1.SelectedItem.ToString() +"";



作此修改后,程序可以正常运行。

参考其他大牛们的博文,这里还可能出现其他问题,一并附上,为以后进一步编写做准备:
http://blog.csdn.net/ls870061011/article/details/8755219
要点摘录:

检查发现是QueryFilter.WhereClause语句在查询shapefile格式的图层出现了问题,打开ArcGIS比较了两种格式的属性查询存在以下的区别:

1.shapefile的字段名用双引号如:"fieldName"而GDB的采用[fieldName]格式;

2.shapefile的模糊查询用like '%A%' 而GDB用like '*A*' ;

3.shapefile的非字符字段不支持模糊查询而GDB格式的支持

所以在查询前必须判断一下图层的数据源类型:
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
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: