IT_C_H_KC

Add-In - SdeWorkspaceFactory & Layer

Discussion created by IT_C_H_KC on May 23, 2012
Hello ,

there is an extension already migrated from extension (ArcGis 9.x) to Add-In concept (ArcGis 10) as a toolbar with a dockable window (not yet a 'real' extension).
The main datasource is ArcSDE. The single datasources are wrapped via files (layer files | *.lyr, tables | *.tab) or direct usage of a connection with a QueryFilter.
There was and still is a general function dealing with the setup of the connection using a PropertySet.
    Public Function sdeConnect(ByVal strUser As String, ByVal strPasswort As String) As Boolean
        Try
            gConnProp = New PropertySet
            With gConnProp
                .SetProperty("SERVER", My.Resources.Resource1.strSDEServer)
                .SetProperty("INSTANCE", My.Resources.Resource1.strSDEInstance)
                .SetProperty("DATABASE", My.Resources.Resource1.strSDEDatabase)
                .SetProperty("VERSION", My.Resources.Resource1.strSDEVersion)
            End With

            Dim factoryType As Type = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory")
            gSDEWorkFact = CType(Activator.CreateInstance(factoryType), IWorkspaceFactory2)           

            'gSDEWorkSpace = gSDEWorkFact.Open(gConnProp, gApplication.hWnd)
            gSDEWorkSpace = gSDEWorkFact.Open(gConnProp, 0)
           
            Return True
            Exit Function
        Catch ex As Exception         
            'further code removed 
        End Try
    End Function

The dialog is prompting as expected (leaving user name and password blank) and the connection is set up after filling in the missing information.

Afterwards e.g. a layer file is used to add the data:
     Public Sub openLyr(ByVal strPath As String)
        Dim pGxLayer As IGxLayer        
        Dim pGxFile As IGxFile
  
        pGxLayer = New GxLayer
        pGxFile = pGxLayer        

        pGxFile.Path = strPath       
        Dim pLayer As ILayer2       
        pLayer = pGxLayer.Layer
  
  'further code removed
  '
  '
 End Sub


The problem is that the created workspace is not used by the datasource *.lyr.
(I was not able to assign e.g. the created FeatureWorkspace.)
So the user is forced to input username and password twice.

If I leave out the standard function (sdeConnect) for the general SDE connection it prompts only once but the other datasources are not working because they need the connection and workspace.

How can I manage that the connection window/prompt is shown up only once?
In the former extension it worked that way.

(Maybe getting the used application sde workspace for the other datasources could also solve the problem.)



Thanks in advance!

Outcomes