[Visual Basic 6.0]'* The example shows how to execute QueryFeatureData2() function
'* to get a subset of features from geoprocessing service result
'* and show them in a table window.
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocumentDim pMap As IMap
Set pMap = pMxDoc.FocusMap'******
'Getting LayerDescription object from the result sublayer
'******
'Getting a refence of geoprocessing result layer
Dim pGPResultLyr As IMapServerLayer
Set pGPResultLyr = pMap.Layer(0)
'QI to ICompositeLayer to get access the sublayer of geoprocessing result layer
Dim pGPComLyr As ICompositeLayer
Set pGPComLyr = pGPResultLyr
'Accessing the first sublayer - which is a ToolLayer
Dim pGPCompToolLyr As ICompositeLayer
Set pGPCompToolLyr = pGPComLyr.Layer(0)
'getting LayerDescription from GP Result sub layer within the tool layer
Dim pGPToolSubLyr As IMapServerSublayer2
Set pGPToolSubLyr = pGPCompToolLyr.Layer(0)
Dim pGPToolSubLyrDesc As ILayerDescription2
Set pGPToolSubLyrDesc = pGPToolSubLyr.LayerDescription'***************
'Getting referece to the MapServer from the MapServerLayer
'***************
'Getting connection information
Dim pAGSSONm As IAGSServerObjectName
Dim strMapName As String
pGPResultLyr.GetConnectionInfo pAGSSONm, "", strMapName'Getting MapServer object from AGSServerObjectName
Dim pName As IName
Set pName = pAGSSONm
Dim pAGSSO As IAGSServerObject
Set pAGSSO = pName.Open
Dim pMapServer2 As IMapServer2
Set pMapServer2 = pAGSSO'**************
'Executing Query against a geoprocessing result
'**************
'Specifying output format of the query
Dim pQRO As IQueryResultOptions
Set pQRO = New QueryResultOptions
pQRO.Format = esriQueryResultRecordSetAsObject
Dim pQR As IQueryResult
' here you may want to use a IQueryFilter object instead of Nothing
Set pQR = pMapServer2.QueryFeatureData2(pMapServer2.DefaultMapName, pGPToolSubLyrDesc, Nothing, pQRO)
'Getting RecordSet object
Dim pRS As IRecordSet2
Set pRS = pQR.Object'**************
'Showing the result in a table window
'**************
Dim pTable As ITable
Set pTable = pRS.Table 'saving records in a scratch table
Dim pDS As IDataset
Set pDS = pTable
pDS.Rename "MapServerQuery" 'giving a meaningful nameDim pStandAloneTable As IStandaloneTable
Set pStandAloneTable = New StandaloneTable
Set pStandAloneTable.Table = pTableDim pTableWindow As ITableWindow2
Set pTableWindow = New TableWindow
Set pTableWindow.StandaloneTable = pStandAloneTable
Set pTableWindow.Application = Application
pTableWindow.Show (True)
[Visual Basic .NET, C#, C++]
No example is available for Visual Basic .NET, C#, or C++. To view a Visual Basic 6.0 example, click the Language Filter button
in the upper-left corner of the page.