ArcEngine10.1直连Oracle
好久没写AE的东西了,好多东西都忘记了,这里记录一下直连Oracle,注意instance的拼接。
/// <summary> /// 连接Oracle数据库SDE /// </summary> /// <param name="sAddress">连接IP</param> /// <param name="sInstance">数据库实例名orcl</param> /// <param name="sUser">用户名</param> /// <param name="sPassword">密码</param> /// <returns></returns> public IWorkspace Con2OracleSDE(string sAddress, string sInstance, string sUser, string sPassword) { IWorkspaceFactory pSdeWksFactory = new SdeWorkspaceFactory(); IWorkspace pWorkspace = null; try { IPropertySet propSet = new PropertySetClass(); propSet.SetProperty("server", sAddress); //propSet.SetProperty("instance", "sde:oracle11g:" + sAddress + @"/" + sDBName); //propSet.SetProperty("instance", "sde:oracle11g:" + sDBName); propSet.SetProperty("instance", "sde:oracle11g$//" + sAddress + "/" + sInstance); propSet.SetProperty("user", sUser); propSet.SetProperty("password", sPassword); propSet.SetProperty("version", "SDE.DEFAULT"); pWorkspace = pSdeWksFactory.Open(propSet, 0); return pWorkspace; } catch (Exception ex) { return null; } }
另外也可以通过ArcCatalog中配置的数据库连接(.sde文件)进行数据库连接。
posted on 2022-01-18 09:50 jingkunliu 阅读(161) 评论(0) 编辑 收藏 举报