zoukankan      html  css  js  c++  java
  • 连接SDE数据库hl3292修改已解决

    http://giscolor.bokee.com/viewdiary.40978046.html

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    //ESRI
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.DataSourcesGDB;

    // ArcGIS Engine引用
    using ESRI.ArcGIS.SystemUI;
    using ESRI.ArcGIS.Carto;
    using ESRI.ArcGIS.Display;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.ToolbarControl;
    using ESRI.ArcGIS.TOCControl;
    //using ESRI.ArcGIS.MapControl;
    using ESRI.ArcGIS.PageLayoutControl;
    using ESRI.ArcGIS.Controls;
    using ESRI.ArcGIS.GlobeCore;
    using System.Runtime.InteropServices;

      /// <summary>
            /// 连接sde数据库,并设定map的图层
            /// </summary>
            private void GetSdeData()
            {
                /**连接sde数据库**/
                //License
                IAoInitialize pAoInit = new AoInitializeClass();
                pAoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcView);

                //Workspace
                IWorkspaceFactory pWorkspaceFactory;
                pWorkspaceFactory = new SdeWorkspaceFactoryClass();

                //PropertySet
                IPropertySet pPropertySet;
                pPropertySet = new PropertySetClass();
                pPropertySet.SetProperty("Service", "esri_sde");
                pPropertySet.SetProperty("Server", "192.168.25.110");
                //pPropertySet.SetProperties("Database","wjgis");
                pPropertySet.SetProperty("Instance", "port:5151");
                pPropertySet.SetProperty("user", "sangis");
                pPropertySet.SetProperty("password", "sangis");
                pPropertySet.SetProperty("version", "sde.DEFAULT");

                //IFeatureWorkspace对象
                IFeatureWorkspace pSdeWorkspace;

                IFeatureDataset pFeatureDataset;
                IFeatureClass pFeatureClass;

                //图层
                IFeatureLayer layer;


                try
                {
                    //连接
                    pSdeWorkspace = (IFeatureWorkspace)pWorkspaceFactory.Open(pPropertySet, 0);
                    //取数据
                    pFeatureClass = pSdeWorkspace.OpenFeatureClass("TV井盖");
                    //定义图层
                    layer = new FeatureLayerClass();
                    //设定layer的FeatureClass属性
                    layer.FeatureClass = pFeatureClass;
                    //设定Map的图层
                    MapControl.Map.AddLayer(layer);
                }
                catch (Exception ex)
                {

                    MessageBox.Show("SDE数据库不能连接!" ex.Message);
                    //text_sqlfilter.Text = ex.Message;
                }
            }

  • 相关阅读:
    python 多进程队列数据处理
    python mqtt 客户端实现
    elasticsearch 父子关系
    elasticsearch Mapping使用自定义分词器
    elk 解决浏览器跨域问题
    elasticsearch 英文数字组合字符串模糊检索
    elasticsearch 关联单词查询以及Shingles
    elasticsearch 分析器 分词器
    Leetcode: Binary Tree Postorder Traversal
    Leetcode: Binary Tree Preorder Traversal
  • 原文地址:https://www.cnblogs.com/hl3292/p/1853067.html
Copyright © 2011-2022 走看看