how to get source sde database type of layer

The sample below shows how to get source sde database type of layer.

It uses IDataLayer2 and IDatabaseConnectionInfo2 interface.

  •  IDataLayer2  : Provides access to additional members that control the data source properties of a layer.
  •  IDatabaseConnectionInfo2 : Provides access to members that provide information about the Workspace's  connected database.

 

 

Private Function getDBType(pLayer As ILayer) As String
    
Dim pDataLayer As IDataLayer2
    
Set pDataLayer = pLayer
    
    
Dim pDatasetName As IDatasetName
    
Set pDatasetName = pDataLayer.DataSourceName
    
    
Dim pWorkspaceName As IWorkspaceName
    
Set pWorkspaceName = pDatasetName.WorkspaceName
    
    
Dim pName As IName
    
Set pName = pWorkspaceName
    
    
Dim pWorkSpace As IWorkspace
    
Set pWorkSpace = pName.Open
    
    
Dim pDBConnInfo As IDatabaseConnectionInfo2
    
Set pDBConnInfo = pWorkSpace
   
    
Select Case pDBConnInfo.ConnectionDBMS
        
Case esriDBMS_Oracle
             getDBType 
= "ORACLE"
        
Case esriDBMS_SQLServer
             getDBType 
= "SQLSERVER"
        
Case esriDBMS_SQLServer
             getDBType 
= "DB2"
        
Case esriDBMS_Unknown
             getDBType 
= "UNKNOWN"
    
End Select

End Function

 

posted on 2009-05-15 10:24  炜升  阅读(255)  评论(0编辑  收藏  举报