码迷,mamicode.com
首页 > 数据库 > 详细

C#打开SDE数据库的几种方式总结

时间:2017-05-21 17:45:26      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:默认   property   .net   ase   文件   font   bsp   art   data   

转自谢灿软件原文 C#打开SDE数据库的几种方式总结

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

 

    /// <param name="server">数据库服务器名</param>  
    /// <param name="instance">SDE的端口,默认安装时"port:5151"</param>  
    /// <param name="user">SDE的用户名</param>  
    /// <param name="password">密码</param>  
    /// <param name="database">数据库的名字</param>  
    /// <param name="version">SDE的版本</param>  
    /// <returns></returns>  
    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.通过连接字符串打开数据库

 

/// <param name="connectionString">连接字符串</param>  
/// For example, "SERVER=Kona;DATABASE=sde;INSTANCE=5151;USER=Editor;PASSWORD=Editor;VERSION=sde.DEFAULT"  
/// <returns></returns>  
public IWorkspace OpenSdeWorkspaceByConnectionString(string connectionString)  
{  
    IWorkspaceFactory2 workspaceFactory = new SdeWorkspaceFactoryClass();  
    return workspaceFactory.OpenFromString(connectionString, 0);  
} 

 

 

 

3.通过sde文件打开数据库

 

    /// <param name="connectionFile">sde文件</param>  
    /// For example, "C:\\Data.sde"  
    /// <returns></returns>  
    public IWorkspace OpenSdeWorkspaceFromFile(string connectionFile)  
    {  
        IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();  
        return workspaceFactory.OpenFromFile(connectionFile, 0);  
    }  

 

C#打开SDE数据库的几种方式总结

标签:默认   property   .net   ase   文件   font   bsp   art   data   

原文地址:http://www.cnblogs.com/arxive/p/6885266.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!