public IWorkspace OpenSDE(string serverIP,string instance,string database,string user,string password,string version="sde.DEFAULT")
{
IWorkspace xSdeWorkspace = null;
IPropertySet xPropertySet = new PropertySetClass();
xPropertySet.SetProperty("Server", serverIP);//本机IP地址+端口
xPropertySet.SetProperty("Instance", instance);//可以去ArcMap中找到SDE数据库,然后查看具体实例(如:sde:oracle11g:orcl)。注意远程直连时,instance需要加上ip和port,并用$连接,如sde:oracle11g$ip:port/orcl
xPropertySet.SetProperty("Database", database);//orcl
xPropertySet.SetProperty("User", user);
xPropertySet.SetProperty("Password", password);
xPropertySet.SetProperty("Version", version);
//对于没有使用版本或者第一次连接(没有建立空间数据库,当然没有版本了). 该处使用sde.DEFAULT这个版本。这是默认的版本。
IWorkspaceFactory2 xSdeWorkspaceFactory2 = new SdeWorkspaceFactoryClass();
xSdeWorkspace = xSdeWorkspaceFactory2.Open(xPropertySet, 0);
return xSdeWorkspace;
}
AE连接SDE数据库
最新推荐文章于 2023-06-01 20:35:44 发布