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. 【python问题系列--1】SyntaxError:Non-ASCII character '\xe5' in file kNN.py on line 2, but no encoding declared;

    因为Python在默认状态下不支持源文件中的编码所致.解决方案有如下三种: 一.在文件头部添加如下注释码: # coding=<encoding name> 例如,可添加# coding= ...

  2. mysql -- 备忘

    select distinct(authorid),author from forum_post where tid=1;

  3. PHP的几个常用加密函数【转载】

    转自 https://jellybool.com/post/php-encrypt-functions 在网站的开发过程中,常常需要对部分数据(如用户密码)进行加密,本文主要介绍PHP的几个常见的加密 ...

  4. MySQL外键的作用和创建

    MySQL外键的作用: 保持数据一致性,完整性,主要目的是控制存储在外键表中的数据.使两张表形成关联,外键只能引用外表中列的值! 我们来建两个表 CREATE TABLE `example1` ( ` ...

  5. Qt学习之系列[9] – QCoreApplication:processEvents()可能会引起递归,导致栈溢出崩溃

    api含义:QCoreApplication::processEvents() 将处理所有事件队列中的事件并返回给调用者. 问题描述: 当主线程在某个槽函数里正在执行processEvents时, 刚 ...

  6. storm serializable

    http://www.programgo.com/article/68283366567/

  7. 【素数】 poj 2739 一个数能有多少种连续素数相加方案

    简单题 素数打表   根据数据量  用n2算法遍历  开一个save[k]素数存前k个素数和即可. #include <iostream> #include <cstdio> ...

  8. jquery 左边分类+插件

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. Java NIO Related

    A file's status is 3-valued: The file is verified to exist; The file is verified to not exist; The f ...

  10. Python 文件Hash(MD5,SHA1)

    import hashlib import os,sys   def CalcSha1(filepath):     with open(filepath,'rb') as f:         sh ...