IWorkspace接口提供访问工作空间的通用属性和方法,如它的连接属性,以及包含的数据集的方法。

IWorkspace的成员字段:

Members

 

Description

ConnectionProperties

The connection properties of the workspace.

DatasetNames

The DatasetNames in the workspace.

Datasets

The datasets in the workspace.

ExecuteSQL

Executes the specified SQL statement.

Exists

Checks if the workspace exists.

IsDirectory

TRUE if the workspace is a file system directory.

PathName

The file system full path of the workspace.

Type

The Type of the Workspace.

WorkspaceFactory

The factory that created the workspace.

如何打开一个数据库

要打开一个数据库,也就意味着我们要得到那个工作空间,而工作空间是一个普通类,也就意味着我们只

能从其他类来得到这个工作空间,这个类就是工作空间工厂(WorkspaceFactory),而这个类又是一个抽

象类,也就意味着我们只能使用它的子类来实例化一个对象,WorkspaceFactory有众多的子类

IWorkSpaceFactory是Geodatabase的入口,它定义了数据库的通用属性,比如打开,创建等,我们在ArcGIS Engine的帮助中可以详细的得到它的信息,如下图:

Members

   

Description

 

ContainsWorkspace

Indicates if parentDirectory contains a valid workspace, or is a valid file-system workspace.

 

Copy

Copies a workspace to the specified destination folder.

 

Create

Creates a new workspace specified by the directory, file name, and connection properties.

 

GetClassID

The class ID of the WorkspaceFactory.

 

GetWorkspaceName

Retrieves the workspace name of a workspace from the given list of file names.

 

IsWorkspace

True if the specified file identifies a workspace supported by the workspace factory.

 

Move

Moves a workspace to the specified destination folder.

 

Open

Opens the workspace specified by the connection properties.

 

OpenFromFile

Opens the workspace specified by the given file name.

 

ReadConnectionPropertiesFromFile

The connection properties from the specified file.

 

WorkspaceDescription

A singular or plural description of the type of workspace the workspace factory opens/creates.

 

WorkspaceType

The type of workspace the workspace factory opens/creates.

打开数据库有两种方式,从上面的图表中也可以看出OpenFromFile方法和Open方法,这两者的区

方法中的参数不同,其中Open方法需要一个IPropertySet对象,这个方法我们经常在打开SDE数

使用,注意(这个方法同样可以用来打开个人数据库,文件数据库)。

打开个人数据库

public IWorkspace GetMDBWorkspace(String _pGDBName)

{

IWorkspaceFactory pWsFac = new AccessWorkspaceFactoryClass();

IWorkspace pWs = pWsFac.OpenFromFile(_pGDBName,0);

return pWs;

}

}

打开文件数据库

public IWorkspace GetFGDBWorkspace(String _pGDBName)

{

IWorkspaceFactory pWsFac = new FileGDBWorkspaceFactoryClass();

IWorkspace pWs = pWsFac.OpenFromFile(_pGDBName, 0);

return pWs;

}

打开SDE数据库

打开SDE数据库我们使用的是Open方法,要用这个方法,我们就要对IPropertySet对象设置,要打开SDE

数据库,我们要获取SDE数据库的服务器地址,数据库实例,数据库,用户,密码等参数。而IPropertySet

就好比一个Key-Value的对象,用来帮组我们设置这些,然后传到Open方法中。

public IWorkspace GetSDEWorkspace(String _pServerIP, String _pInstance, String _pUser, String

_pPassword, String _pDatabase, String _pVersion)

{

ESRI.ArcGIS.esriSystem.IPropertySet pPropertySet = new

ESRI.ArcGIS.esriSystem.PropertySetClass();

pPropertySet.SetProperty("SERVER", _pServerIP);

pPropertySet.SetProperty("INSTANCE", _pInstance);

pPropertySet.SetProperty("DATABASE", _pDatabase);

pPropertySet.SetProperty("USER", _pUser);

pPropertySet.SetProperty("PASSWORD", _pPassword);

pPropertySet.SetProperty("VERSION", _pVersion);

ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 workspaceFactory;

workspaceFactory = (ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2)new

ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();

return workspaceFactory.Open(pPropertySet, 0);

}

IWorkSpace接口介绍 1.打开各种数据库的更多相关文章

  1. IWorkSpace接口介绍

    IWorkspace接口提供访问工作空间的通用属性和方法,如它的连接属性,以及包含的数据集的方法. 如何打开一个数据库  要打开一个数据库,也就意味着我们要得到那个工作空间,而工作空间是一个普通类,也 ...

  2. 如何删除要素类 IFeatureWorkspace 接口介绍(1)

    如何删除要素类 要想删除一个要素类,那么必须先得到这个,在得到这个要素类的时候,我们要学习一个新的接口IFeatureWorkspace. IFeatureWorkspace  接口介绍 这个接口主要 ...

  3. ArcEngine打开本地数据库

    先看一下GeoDatabase核心结构模型图: 1  工作空间工厂WorkspaceFactory对象 WorkspaceFactory是GeoDatabase的入口,是一个抽象类,拥有很多子类,例如 ...

  4. Hive 接口介绍(Web UI/JDBC)

    Hive 接口介绍(Web UI/JDBC) 实验简介 本次实验学习 Hive 的两种接口:Web UI 以及 JDBC. 一.实验环境说明 1. 环境登录 无需密码自动登录,系统用户名shiyanl ...

  5. 通过ODBC接口访问人大金仓数据库

      国产化软件和国产化芯片的窘境一样,一方面市场已经存在性能优越的同类软件,成本很低,但小众的国产化软件不仅需要高价买入版权,并且软件开发维护成本高:另一方面,国产软件目前普遍难用,性能不稳定,Bug ...

  6. SSH动态查询封装接口介绍

    SSH动态查询封装接口介绍 1.查询记录总条数 public int count(Class c,Object[][] eq,Object[][] like,String[] group,String ...

  7. 【百度地图API】如何在地图上添加标注?——另有:坐标拾取工具+打车费用接口介绍

    原文:[百度地图API]如何在地图上添加标注?--另有:坐标拾取工具+打车费用接口介绍 摘要: 在这篇文章中,你将学会,如何利用百度地图API进行标注.如何使用API新增的打车费用接口. ------ ...

  8. Redis --> Redis的接口介绍及使用

    Redis的接口介绍及使用 Redis是一个远程内存数据库,它不仅性能强劲,而且还具有复制特性以及为解决问题而生的独一无二的数据模型.Redis提供了5种不同类型的数据结构,各式各样的问题都可以很自然 ...

  9. go语言之进阶篇文件常用操作接口介绍和使用

    一.文件常用操作接口介绍 1.创建文件 法1: 推荐用法 func Create(name string) (file *File, err Error) 根据提供的文件名创建新的文件,返回一个文件对 ...

随机推荐

  1. HDU 5963 博弈

    http://acm.hdu.edu.cn/showproblem.php?pid=5963 题目大意:中文题 思路:看ICPC camp好了,简单易懂:https://async.icpc-camp ...

  2. QT插件和服务培训

    下载地址:http://files.cnblogs.com/files/senior-engineer/%E6%8F%92%E4%BB%B6%E5%92%8C%E6%9C%8D%E5%8A%A1%E5 ...

  3. mongodb分片

    在系统早期,数据量还小的时候不会引起太大的问题,但是随着数据量持续增多,后续迟早会出现一台机器硬件瓶颈问题的.而mongodb主打的就是海量数据架构,他不能解决海量数据怎么行!不行!“分片”就用这个来 ...

  4. mysql 中tinytext、text、mediumtext和longtext详解

    一.数字类型 类型 范围 说明   Char(N) [ binary] N=1~255 个字元binary :分辨大小写 固定长度 std_name cahr(32) not null VarChar ...

  5. C语言头文件

    最近在工作当中遇到了一点小问题,关于C语言头文件的应用问题,主要还是关于全局变量的定义和声明问题.学习C语言已经有好几年了,工作使用也近半年了,但是对于这部分的东西的确还没有深入的思考过.概念上还是比 ...

  6. HDU 1010 Tempter of the Bone DFS(奇偶剪枝优化)

    需要剪枝否则会超时,然后就是基本的深搜了 #include<cstdio> #include<stdio.h> #include<cstdlib> #include ...

  7. 内联函数 inline 漫谈

    内联函数存在的结论是: 引入内联函数是为了解决函数调用效率的问题 由于函数之间的调用,会从一个内存地址调到另外一个内存地址,当函数调用完毕之后还会返回原来函数执行的地址.函数调用会有一定的时间开销,引 ...

  8. scull_p_read()函数分析

    /* * Data management: read and write */ static ssize_t scull_p_read (struct file *filp, char __user ...

  9. jQuery checkbox 全选

    jQuery 1.6版本以后 if($("#id").attr("checked")) 不能返回 ture 和 false 高版本中jQuery 提供prop ...

  10. Win7下配置Django+Apache+mod_wsgi+Sqlite

    搭建环境: win7 64位 Django 1.8.5 Apache2.4.17 mod_wsgi_ap24py27.so Python2.7.9 1 安装Apache 下载Apache Haus版, ...