文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>连接SDE数据库

连接SDE数据库

时间:2010-10-16  来源:hl3292

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);
                //取数据
                pFeatureDataset = pSdeWorkspace.OpenFeatureDataset("buj");
                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;
            }
        }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载