阅读:3743回复:12
[求助]我在用searchexpression时的问题?
<P>我在查找时,明明属性数据库中有的数据为什么用searchexpression查不出来?</P>
<P>比如:</P> <P>Set recs =map1.Layers(0).SearchExpression(Text1.text)</P> <P>结果出来,没有记录,怎么回事?</P> <img src="images/post/smile/dvbbs/em08.gif" /><img src="images/post/smile/dvbbs/em08.gif" /> |
|
|
1楼#
发布于:2007-06-13 22:24
HELP FOR NEED
<P>首先,查询表达式要正确,例如:</P>
<P>Private Sub Command1_Click()</P> <P>Dim moRecset As MapObjects2.Recordset<BR>Dim recSelection As MapObjects2.Recordset</P> <P>Dim Poly As New MapObjects2.Polygon</P> <P>Dim Poly1 As New MapObjects2.Polygon</P> <P>Set moRecset= Nothing'清空数据集</P> <P>Set moRecset = Map1.Layers("country").Records</P> <P>Dim Expression As String</P> <P>'查询字符型moRecset是表示记录集,后面会提到,Fields表示字段,Name表示字段名</P> <P>If moRecset.Fields("Name").Type = moString Then</P> <P>Expression = "CNTRY_NAME = 'China' " '注意,字符是单引号</P> <P>Else</P> <P><BR>Expression = "ID=0"</P> <P>End If</P> <P>'recSelection 为选择记录集赋值 </P> <P> Set recSelection = Map1.Layers("country").SearchExpression(Expression)<BR> If recSelection.EOF Then '判断recSelection不为空<BR> MsgBox "您所查找的信息不存在,请核对你的输入", vbOKOnly, "温馨的提示您!"</P> <P>Exit sub<BR> End If<BR> recSelection.MoveFirst' 移动到首记录<BR> Do While Not recSelection.EOF</P> <P>'获得找到记录的空间位置,SHAPE表示要素</P> <P> Set Poly = recSelection.Fields("Shape").Value <BR> recSelection.MoveNext 移动到下一条记录<BR><BR> For i = 0 To Poly.Parts.Count - 1<BR> Poly1.Parts.Add Poly.Parts(i) 'Poly1用于多项查询,将查询到的对象一起显示<BR> Next<BR> Loop<BR> Map1.FlashShape Poly1, 3 '闪烁Poly1<BR> Map1.TrackingLayer.Refresh (True)<BR> Set Poly1 = Nothing</P> <P>End Sub</P> |
|
2楼#
发布于:2007-06-11 14:16
<P>假如写成recs=map1.layers(0).searchexpression("名称=text1.text")应该符合SQL要求了吧,为什么总是说"要求对象"呢?</P>
|
|
3楼#
发布于:2004-11-08 17:50
<img src="images/post/smile/dvbbs/em06.gif" /><img src="images/post/smile/dvbbs/em05.gif" />
|
|
4楼#
发布于:2004-09-20 09:04
<P>谢谢大家,解决了该问题。</P>
|
|
|
5楼#
发布于:2004-09-17 10:58
<P>recs.count=-1并不表示没有记录返回</P><P>你可以看看mo的参考里面对count这个属性有详细的解释</P><P>The Count property may return a value of -1 when the object is a Recordset derived from sources which do not contain header information such as:</P><P>1.an SDE layer
2.a Table object 3.a SearchExpression</P><P>In these cases, to obtain the correct Count of the Recordset, a Statistics object should be created from the Recordset, and the number of records taken from the Count property of this Statistics object.</P> |
|
6楼#
发布于:2004-09-15 10:00
text1.text通常是个数值吧,但是serachExpression后面的参数是个表达式,如:id>100
|
|
7楼#
发布于:2004-09-14 22:32
<P>你加上 order by 应该就可以了的 </P><P> field = '2' order by field </P>
|
|
8楼#
发布于:2004-09-14 08:54
是没有记录,recs.count=-1, 现在还没有解决!
|
|
|
9楼#
发布于:2004-09-14 08:44
recs.Eof为真还是为假?
|
|
|
上一页
下一页