Feature classes in ArcSDE with .NET

576
2
09-26-2013 11:45 AM
SugihonoBudiman
New Contributor II
What is the recipe to lists all of the feature classes from ArcSDE SQL backend database. I was able to create the connection but need to know how do it from .NET. Many of the samples out there are either gdb or mdb. I want to stay away from file based.
0 Kudos
2 Replies
NeilClemmons
Regular Contributor III
It's the same thing regardless of workspace type.  Call IWorkspace.Dataset (or DatasetNames) and pass in esriDTFeatureClass.  To get feature classes that reside in feature datasets, call .Dataset and pass in esriDTFeatureDataset.  You'll then need to loop through each feature dataset's Subsets enum.
0 Kudos
SugihonoBudiman
New Contributor II
Neil - thanks for your reply. I used to code in avenue and left GIS for a while. Now I am back with .net background but clueless. Please help at your mercy. Or if you can point me to the documents that I've been looking for hours that would be great.

Try

            If (Not ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Engine)) Then
                If (Not ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop)) Then
                    Console.WriteLine("This application could not load the correct version of ArcGIS.")
                End If
            End If

            Dim aoLicenseInitializer As LicenseInitializer
            aoLicenseInitializer = New LicenseInitializer

            'ESRI License Initializer generated code.
            If (Not aoLicenseInitializer.InitializeApplication(New esriLicenseProductCode() {esriLicenseProductCode.esriLicenseProductCodeEngine, esriLicenseProductCode.esriLicenseProductCodeStandard, esriLicenseProductCode.esriLicenseProductCodeAdvanced}, _
      New esriLicenseExtensionCode() {esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork})) Then
                Console.WriteLine("This application could not initialize with the correct ArcGIS license and will shutdown. LicenseMessage: " + aoLicenseInitializer.LicenseMessage())
                aoLicenseInitializer.ShutdownApplication()
                Return
            End If

            Dim gp As Workspace = openSDEWorkspace("server", "sde:sqlserver:sqlserver", "username", "password", "sqldb", "dbo.Default")
         


        Catch ex As ESRI.ArcGIS.RuntimeManagerException

            Console.WriteLine(ex.ToString)

        End Try

        Console.Read()
0 Kudos