Select to view content in your preferred language

How to Convert a GlobalID field to a GUID field.

2955
1
02-18-2016 12:05 PM
JoseSanchez
Regular Contributor

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
1 Reply
rbae
by
New Contributor III

This is actually mind boggling.  It looks like it worked, and behaves like it worked until you close the connection.  Next time in, the field is a GLOBALID again and not a GUID.

0 Kudos