1.通过指定连接属性参数打开数据库

public IPropertySet ConnectSdeSQL(string sAddress, string sDBName, string sUser, string sPassword)

        {

            IPropertySet propSet = new PropertySetClass();

            propSet.SetProperty("SERVER", sAddress);//服务器地址,如:192.168.34.152

            propSet.SetProperty("INSTANCE", "sde:sqlserver:" + sAddress + "");//连接实例,如sde:sqlserver:192.168.34.152

            propSet.SetProperty("DATABASE", sDBName);//要连接的数据库名称

            propSet.SetProperty("USER", sUser);//用户名

            propSet.SetProperty("PASSWORD", sPassword);密码

            propSet.SetProperty("VERSION", "DBO.DEFAULT");//数据库的拥有者也就是数据库的架构,一般是DBO或SDE

            propSet.SetProperty("AUTHENTICATION_MODE", "DBMS");

            return propSet;

        }

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);  

}

相关文章:

  • 2021-11-28
  • 2021-11-23
  • 2021-11-23
  • 2021-12-23
  • 2021-11-30
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-16
  • 2022-12-23
  • 2021-09-28
  • 2021-07-27
相关资源
相似解决方案