Необходимо на карту из базы данных нанести выборку данных на карту.0 слой с необходимыми параметрами создан. База данных mdb.
Для выборочного нанесение на карту я использую приведенную ниже процедуру. Прога переделана из примера.
При компиляции ошибок нет. При выполнении pObjectLoader.LoadObjects происходит ошибка в окне записано
"В результате вызова компонента COM возращена ошибка в формате HRESULT E_FAIL"
В чем и здесь есть возможная ошибка. И если есть другой способ реализации подобной задачи.
Код:
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
On Error GoTo EH
' Get the Editor, there must be an edit session active
'Dim app As IApplication
Dim pEditor As IEditor
Dim pID As New UID
pID.Value = "esriEditor.Editor"
pEditor = My.ArcMap.Application.FindExtensionByCLSID(pID)
' Set up the output feature classes, i.e. the destination
Dim pOutFClass As IFeatureClass
Dim pFeatLayer As IFeatureLayer
Dim pDoc As IMxDocument
Dim pMap As IMap
pDoc = My.ArcMap.Application.Document
pMap = pDoc.FocusMap
pFeatLayer = pMap.Layer(0)
pOutFClass = pFeatLayer.FeatureClass
' Set up the input feature classe, i.e. the data source
Dim pInFClass As IFeatureClass
Dim pFeatWS As IFeatureWorkspace
'свое подключение заместо стондартного
'Dim pWSF As IWorkspaceFactory
'pWSF = New ShapefileWorkspaceFactory
'pFeatWS = pWSF.OpenFromFile(files, 0)
'pInFClass = pFeatWS.OpenFeatureClass("states")
pFeatWS = openFGDBWS(files)
pInFClass = pFeatWS.OpenFeatureClass("cntrs1l")
' Specify a subset of the input data
Dim pQueryFilter As IQueryFilter
pQueryFilter = New QueryFilter
pQueryFilter.SubFields = "SHAPE,N_ENCL"
'pQueryFilter.WhereClause = "STATE_NAME = 'Alaska' OR STATE_NAME = 'Hawaii'"
pQueryFilter.WhereClause = "N_ENCL=7"
' OutputFields parameter needs to match sub-fields in input queryfilter
Dim pAllFields As IFields
pAllFields = pOutFClass.Fields
Dim pOutFields As IFields
pOutFields = New Fields
Dim pOutFieldsEdit As IFieldsEdit
pOutFieldsEdit = pOutFields
' Get the query filter sub-fields as an array
' and loop through each field in turn,
' adding it to the ouput fields
Dim sSubFields() As String
sSubFields = Split(pQueryFilter.SubFields, ",")
Dim i, j As Long
For j = LBound(sSubFields) To UBound(sSubFields)
i = pAllFields.FindField(sSubFields(j))
If i = -1 Then
MsgBox("field not found:" & sSubFields(j))
Exit Sub
End If
pOutFieldsEdit.AddField(pAllFields.Field(i))
Next j
Dim pObjectLoader As IObjectLoader
pObjectLoader = New ObjectLoader
Dim pEnumInvalidObject As IEnumInvalidObject
pObjectLoader.LoadObjects(pEditor, _
pInFClass, pQueryFilter, _
pOutFClass, pOutFields, _
False, 0, False, False, 10, _
pEnumInvalidObject)
Dim pInv