Select to view content in your preferred language

Fetching SDE Feature Layer properties (9.3.1)

475
0
06-10-2013 05:52 AM
ChrisHills
Regular Contributor
I would like to automate creating some documentation, and to do this I need to query the metadata belonging to an SDE layer. Unfortunately using my code, I receive the following error:-

Run-time error '-2147467259 (80004005)':
Automation error
Unspecified error


Here is the code, with the problem line highlighted:-

Public Sub GetLayerProperties()

Dim pMxDoc As IMxDocument
Dim pEnumLayer As IEnumLayer
Dim pMap As IMap
Dim pFeatureClass As IFeatureClass
Dim pDataSet As IDataset
Dim pFeatureLayer As IFeatureLayer
Dim pUID As New UID


pUID = "{E156D7E5-22AF-11D3-9F99-00C04F6BC78E}"
Set pMxDoc = Application.Document
Set pEnumLayer = pMxDoc.FocusMap.Layers(pUID, True)
pEnumLayer.Reset
Set pFeatureLayer = pEnumLayer.Next

Do Until (pFeatureLayer Is Nothing)
    If TypeOf pFeatureLayer Is IFeatureLayer Then
        Set pFeatureClass = pFeatureLayer.FeatureClass
        Set pDataSet = pFeatureClass.FeatureDataset
        Debug.Print pDataSet.PropertySet.GetProperty("Server")
        Debug.Print pDataSet.PropertySet.GetProperty("Instance")
        Debug.Print pDataSet.PropertySet.GetProperty("Database")
    End If
    
    Set pFeatureLayer = pEnumLayer.Next
Loop

End Sub
0 Kudos
0 Replies