Trying to Select Parcels from a MapServer with a SpatialQuery with an ArcMap 10.00

Discussion created by mblosser on Apr 5, 2012
Latest reply on Apr 6, 2012 by mblosser
I am accessing a  MapServer that has a parcel layer that I am trying to select taxlots with a both a spatial query and an attribute query.  I am accessing the MapServer with a url and am not part of the user AGSusers or Admin groups.

The spatial query is based on a local shape file. Seems simple enough but I get the following error message from  Fiddler:

???Layer not found.7>5 y??H??V?~? "esriCarto.MapServer???

The local shape file and the MapServer layer are both in the same projection.

I am accessing the Mapsever with an IAGSServerConnection Connection.  Code is below:

Dim connectionProperties As IPropertySet = New PropertySetClass()
connectionProperties.SetProperty("Url", "http://www3.multco.us/ArcGIS/Services")
Dim obj As System.Object = Activator.CreateInstance(Type.GetTypeFromProgID("esriGISClient.AGSServerConnectionFactory"))

Dim PEnumSoName As IAGSEnumServerObjectName = AGSServerConnection.ServerObjectNames

            Dim pSOName As IAGSServerObjectName = PEnumSoName.Next
            PEnumSoName = AGSServerConnection.ServerObjectNames

            Do Until pSOName Is Nothing
                If pSOName.Name = "BaseMap/Taxlots" Then Exit Do              

                pSOName = PEnumSoName.Next

            If pSOName Is Nothing Then Exit Sub
            pName = pSOName
            pMapServer = pName.Open


            Dim pMapServerInfo As IMapServerInfo = pMapServer.GetServerInfo(pMapServer.DefaultMapName)
            Dim pMD As IMapDescription = pMapServerInfo.DefaultMapDescription

?????????????????????????????????????????????????????????????????????????????????????????????????????????Add Mapserver layer to Toc???????????????????????????????????????????????????????????????

pMSLayer.ServerConnect(pSOName, pMapServer.DefaultMapName)

            'Add layer to map
           t pMap = mxDocument.FocusMap
            pAV = pMap

????????????????????????????????????????????????????????????????????????Create Spatial Filiter with Attribute query????????????????????????????????????????????????????????????????????????

Dim pSpatialFilter As ISpatialFilter = New SpatialFilter()

            pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelWithin

            Dim sabFeatClass As IFeatureClass = featureLayer.FeatureClass
            Dim sabfeature As IFeature = sabFeatClass.GetFeature(0)

            pSpatialFilter.Geometry = sabfeature.Shape
            pSpatialFilter.GeometryField = sabFeatClass.ShapeFieldName
            pSpatialFilter.WhereClause = "NAME LIKE" + Space(1) + "'" + "UNITED" + "%" + "'"

Dim QRecSet As IRecordSet = pMapServer.QueryFeatureData(pMD.Name, 0, pSpatialFilter) ???Code fails here

            Dim Reccursor As ICursor = QRecSet.Cursor(True)
            Dim row As IRow = Nothing

            Dim Feature As IFeature = Reccursor.NextRow
            While (Feature) IsNot Nothing
                Dim Geometry As IGeometry = Feature.Shape

                    ??????do some stuff??????.

                Feature = Reccursor.NextRow
            End While

How should I be creating the spatial filter? Do I have to create it with a servercontext, 

ISpatialFilter pSpatialFilter = pServerContext.CreateObject(
    "esriGeodatabase.SpatialFilter")as ISpatialFilter;

If I need to create the spatial filter with a ServerContext does anyone have some code that shows doing this with a URL?

Should I be doing something to specify that the Spatial Filter is based on a local shape file?

Should I be using a different type of connection, possibly with the ESRI.ARCGIS.ADF.Connection.AGS Namespace?

Can someone point me in the right direction?

Thanks in advance for any guidance that you can provide.

Best Regards,