打开SDE数据库,并显示图层

Private Sub getSDELayer()
        Dim pMap As IMap
        pMap = AxMapControl1.Map
        Dim pWorkSF As IWorkspaceFactory
        pWorkSF = New SdeWorkspaceFactory
        Dim pPropertySet As IPropertySet
        pPropertySet = New PropertySet
        With pPropertySet
            .SetProperty("Server", "zf")
            .SetProperty("Instance", "esri_sde")
            .SetProperty("user", "sde")
            .SetProperty("password", "sde")
            .SetProperty("version", "sde.DEFAULT")
        End With

        Dim pSdeWS As IWorkspace
        pSdeWS = pWorkSF.Open(pPropertySet, 0)

        Dim pFeatWorkS As IFeatureWorkspace
        pFeatWorkS = pSdeWS

        Dim pFeatDataset As IFeatureDataset
        pFeatDataset = pFeatWorkS.OpenFeatureDataset("SDE.mytest")

        Dim pFeatClassContainer As IFeatureClassContainer
        pFeatClassContainer = pFeatDataset

        Dim i As Integer
        For i = 0 To pFeatClassContainer.ClassCount - 1
            Dim pFeatClass As IFeatureClass
            pFeatClass = pFeatClassContainer.Class(i)
            Dim pFeatLyr As IFeatureLayer
            pFeatLyr = New FeatureLayerClass
            pFeatLyr.FeatureClass = pFeatClass
            pFeatLyr.Name = pFeatClass.AliasName
            pMap.AddLayer(pFeatLyr)
        Next

        AxMapControl1.Refresh()
    End Sub

posted on 2007-07-11 10:58  GIS云中飞鹏  阅读(2439)  评论(0编辑  收藏  举报

导航