ArcObjects Library Reference  (GeoDatabase)    

ISchemaLock Example

[Visual Basic 6.0]
The following example shows how you can use the ISchemLock interface to aquire an exclusive lock on an object class, before modifying its extension class COM component. ' open the workspace Dim pWSF As IWorkspaceFactory Set pWSF = New AccessWorkspaceFactory Dim pWS As IWorkspace Set pWS = pWSF.OpenFromFile("d:\data\testclsext2.mdb", 0) ' QI for IFeatureWorkspace Dim pFeatWS As IFeatureWorkspace Set pFeatWS = pWS ' open the object class whose class schema you want to modify Dim pOc As IObjectClass Dim pTab As ITable Set pTab = pFeatWS.OpenFeatureClass("buildings") Set pOc = pTab ' QI for the IClassSchemEdit interface Dim pOcSchemaEdit As IClassSchemaEdit Set pOcSchemaEdit = pOc ' set an exclusive lock on the class Dim pSchLock As ISchemaLock Set pSchLock = pOc pSchLock.ChangeSchemaLock (esriExclusiveSchemaLock) ' create the IUID object Dim pCUID As IUID Set pCUID = New UID pCUID.Value = "{484F435C-9A08-11D3-815A-0080C78E8371" ' alter the class extension for the class pOcSchemaEdit.AlterClassExtensionCLSID pCUID, Nothing ' release the exclusive lock pSchLock.ChangeSchemaLock (esriSharedSchemaLock)

[C#]

    //ISchemaLock Example

    public void ISchemaLock_Example(IObjectClass objectClass)
    {
        //This functions shows how you can use the ISchemLock interface to aquire
        //an exclusive lock on an object class, before modifying its extension
        //class COM component.
        //cast for the IClassSchemaEdit
        IClassSchemaEdit classSchemaEdit = (IClassSchemaEdit)objectClass;

        //set and exclusive lock on the class
        ISchemaLock schemaLock = (ISchemaLock)objectClass;
        schemaLock.ChangeSchemaLock(esriSchemaLock.esriExclusiveSchemaLock);

        //creat the IUID object
        ESRI.ArcGIS.esriSystem.UID classUID = new ESRI.ArcGIS.esriSystem.UIDClass();
        classUID.Value = "{484F435C-9A08-11D3-815A-0080C78E8371";
       
        //alter the class extension for the class
        classSchemaEdit.AlterClassExtensionCLSID(classUID, null);

        //release the exclusive lock
        schemaLock.ChangeSchemaLock(esriSchemaLock.esriSharedSchemaLock);
    }


[Visual Basic .NET, C++]
No example is available for Visual Basic .NET or C++. To view a Visual Basic 6.0 or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.