AnsweredAssumed Answered

How to Convert a GlobalID field to a GUID field.

Question asked by jsn on Feb 18, 2016

Hello everyone,

 

I am testing the code below and it does not change the type of the field GLOBALID from GlobalId to GUID

 

 

 

ArcObjects 10 .NET SDK Help

 

Environment:

- ArcGIS 10.2

 

- SDE based on Oracle 11G

 

- Visual Studio 2010.

 

 

' Converts a GlobalID field to a GUID field.
    Public Sub ConvertGlobalIdToGuid(ByVal workspace As IWorkspace, ByVal datasetName As String)
        ' Open the table.
        Dim featureWorkspace As IFeatureWorkspace = CType(workspace, IFeatureWorkspace)
        Dim table As ITable = featureWorkspace.OpenTable(datasetName)

        ' Get the GlobalID field.
        Dim classEx As IClassEx = CType(table, IClassEx)
        If Not classEx.HasGlobalID Then
            Throw New Exception(String.Format("No GlobalID column in table: {0}.", datasetName))
        End If
        Dim globalIDFieldName As String = classEx.GlobalIDFieldName

        Try

       
        ' Convert the GlobalID column to a GUID column.
        Dim classSchemaEditEx As IClassSchemaEditEx = CType(table, IClassSchemaEditEx)
        classSchemaEditEx.UnregisterGlobalIDColumn(globalIDFieldName)

        Catch ex As Exception
            Console.WriteLine("Could Not Open Geodatabase")
            Console.WriteLine("{0} ", ex.Message)
        End Try
    End Sub

Outcomes