原来使用Arcgis9.3的版本,现在升级到了10.1遇到不少问题,原来初始化工作空间的代码无法正常运行了,修改后的代码如下:

static void Test()
{
IPropertySet sdeProperties = new PropertySetClass();
sdeProperties.SetProperty("INSTANCE", "sde:oracle10g:T194");
sdeProperties.SetProperty("DATABASE", "sde");
sdeProperties.SetProperty("USER", "sde");
sdeProperties.SetProperty("PASSWORD", "sde");
sdeProperties.SetProperty("VERSION", "sde.DEFAULT"); IWorkspace sdeWorkspace = CreateSdeWorkspace(sdeProperties);
} /// <summary>
/// Retrieves an SDE workspace using the specified property set.
/// </summary>
/// <param name="propertySet">The connection parameters.</param>
/// <returns>An IWorkspace reference to an SDE workspace.</returns>
public static IWorkspace CreateSdeWorkspace(IPropertySet propertySet)
{
// Create the workspace factory and connect to the workspace.
Type factoryType = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);
IWorkspace workspace = workspaceFactory.Open(propertySet, );
return workspace;
}

  

需要注意的地方:

  1. 原来9.3连接实例(INSTANCE)的值为:SDE:ORACLE10G,在10.1中的值改变了,而且必须要小写
  2. 在10.1中参数值:sde:oracle10g:T194,含义:sde:oracle10g为指定应数据和库版,可以查看一下oracle版本,语句:select * from v$instance;T194:对应oracle客户端在Net Manager中的“服务命名”
  3. 这里调用的其实是Desktop中的组件,但Desktop是运行在32位环境的,所以服务器上也必须安装Oracle 32位客户端,顺序是这样的:先安装32位客户端,再安装64位客户端,也可以直接修改环境变量
05-11 15:50