转自原文 ArcSDE:C#打开SDE数据库的几种方式总结
1.通过指定连接属性参数打开数据库
- public IWorkspace OpenSdeWorkspaceByPropertySet(string server, string instance, string user, string password, string database, string version)
- {
- IPropertySet Propset = new PropertySetClass();
- Propset.SetProperty("SERVER", server);
- Propset.SetProperty("INSTANCE", instance);
- Propset.SetProperty("USER", user);
- Propset.SetProperty("PASSWORD", password);
- Propset.SetProperty("DATABASE", password);
- Propset.SetProperty("VERSION", version);
-
- IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();
- return workspaceFactory.Open(Propset, 0);
- }
2.通过连接字符串打开数据库
- public IWorkspace OpenSdeWorkspaceByConnectionString(string connectionString)
- {
- IWorkspaceFactory2 workspaceFactory = new SdeWorkspaceFactoryClass();
- return workspaceFactory.OpenFromString(connectionString, 0);
- }
3.通过sde文件打开数据库
- public IWorkspace OpenSdeWorkspaceFromFile(string connectionFile)
- {
- IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();
- return workspaceFactory.OpenFromFile(connectionFile, 0);
- }
|
请发表评论