<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Enterprise Geodatabase &amp;quot;StartEditing&amp;quot; fails with workspace read-only error in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/enterprise-geodatabase-quot-startediting-quot/m-p/1328784#M20604</link>
    <description>&lt;P&gt;I am migrating an existing Windows application that uses ArcObjects 10.* to the new version ArcGIS 11.1. I found I have to migrate the existing ArcObjects SDK code to ArcGIS Enterprise SDK in the new version to work with the File and Enterprise Geodatabases.&lt;/P&gt;&lt;P&gt;I migrated all the code to &lt;STRONG&gt;ArcGIS Enterprise SDK&lt;/STRONG&gt; and it is working perfectly when connecting and editing a File Geodatabase. But If I try to edit an Enterprise Geodatabase (formerly ArcSDE Geodatabase), I can read it, but unable to edit it. While calling the `IWorkspaceEdit.StartEditing` (line 27 in the below code) it throws&amp;nbsp;&lt;SPAN&gt;ErrorCode:&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;-2147220893&lt;/STRONG&gt;&lt;SPAN&gt;, ErrorMessage: "Workspace or data source is read only"&lt;/SPAN&gt;&lt;SPAN&gt;. But the same code was working before with ArcObjecs to edit ArcSDE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have thoroughly examined all possible causes for this issue and have ensured the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;The database connection has write access; I used the same connection properties and attempted to edit the Enterprise Geodatabase directly in ArcPro, and I was able to make edits.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I have tried different Enterprise Geodatabases, including MS SQL Server and PostgreSQL, and different versions, including 10.7 and 11.1.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I have tested with an Enterprise Geodatabase connection on both a remote machine and a local machine.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Therefore, I suspect that I may be overlooking something related to enabling&amp;nbsp;&lt;STRONG&gt;write-mode&lt;/STRONG&gt;&amp;nbsp;(making it not read-only) either within the Enterprise Geodatabase settings or during Workspace creation. Once this issue is resolved, I can use the same code that worked for the File Geodatabase connection with the Enterprise Geodatabase.&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Here is the code I am using to connect to and edit the Enterprise Geodatabase:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Set up the workspace factory for SQL Server with Database Authentication.
IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();

// Set the connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("DATABASE", "_db_name_");
propertySet.SetProperty("INSTANCE", "sde:sqlserver:" + "_instance_");
propertySet.SetProperty("USER", "_user_");
propertySet.SetProperty("PASSWORD", "_password_");
propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS");
propertySet.SetProperty("VERSION", "dbo.DEFAULT");

IWorkspaceEdit workspaceEdit = null;

try
{
    // Open the connection.
    IWorkspace workspace = workspaceFactory.Open(propertySet, 0);

    if (workspace != null)
    {
        // Check if the workspace supports editing.
        workspaceEdit = (IWorkspaceEdit)workspace;
        if (!workspaceEdit.IsBeingEdited())
        {
            // Start an edit session.
            workspaceEdit.StartEditing(true); //&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; THIS IS WHERE I AM GETTING THE READ-ONLY ERROR &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
            workspaceEdit.StartEditOperation();
        }

        // Open the feature class you want to edit.
        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
        IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("_feature_class_");

        // Create a query filter to find the specific feature to edit.
        IQueryFilter queryFilter = new QueryFilterClass();
        queryFilter.WhereClause = "YourField = 'YourValue'"; // Modify to match your criteria

        // Search for the feature.
        IFeatureCursor featureCursor = featureClass.Search(queryFilter, true);
        IFeature feature = featureCursor.NextFeature();

        if (feature != null)
        {
            // Modify the attributes of the feature as needed.
            feature.set_Value(featureClass.Fields.FindField("AttributeFieldName"), "NewValue");

            // Save the changes.
            feature.Store();
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            Console.WriteLine("Feature edited successfully.");
        }
        else
        {
            Console.WriteLine("Feature not found.");
        }

        // Release resources.
        Marshal.ReleaseComObject(featureCursor);
        Marshal.ReleaseComObject(workspace);
    }
    else
    {
        Console.WriteLine("Failed to connect to the geodatabase.");
    }
}
catch (Exception ex)
{
    Console.WriteLine("Error: " + ex.Message);
}
finally
{
    // Make sure to stop the edit session in the finally block to release locks.
    if (workspaceEdit != null &amp;amp;&amp;amp; workspaceEdit.IsBeingEdited())
    {
        workspaceEdit.StopEditOperation();
        workspaceEdit.StopEditing(true);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;&lt;BR /&gt;Please advise how can I resolve the workspace read-only issue and resolve this problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Are there any special settings I have to do in ArcGIS Enterprise to get this editing work?&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Thank you for your time.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Sep 2023 16:55:50 GMT</pubDate>
    <dc:creator>Vasu80</dc:creator>
    <dc:date>2023-09-14T16:55:50Z</dc:date>
    <item>
      <title>Enterprise Geodatabase "StartEditing" fails with workspace read-only error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/enterprise-geodatabase-quot-startediting-quot/m-p/1328784#M20604</link>
      <description>&lt;P&gt;I am migrating an existing Windows application that uses ArcObjects 10.* to the new version ArcGIS 11.1. I found I have to migrate the existing ArcObjects SDK code to ArcGIS Enterprise SDK in the new version to work with the File and Enterprise Geodatabases.&lt;/P&gt;&lt;P&gt;I migrated all the code to &lt;STRONG&gt;ArcGIS Enterprise SDK&lt;/STRONG&gt; and it is working perfectly when connecting and editing a File Geodatabase. But If I try to edit an Enterprise Geodatabase (formerly ArcSDE Geodatabase), I can read it, but unable to edit it. While calling the `IWorkspaceEdit.StartEditing` (line 27 in the below code) it throws&amp;nbsp;&lt;SPAN&gt;ErrorCode:&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;-2147220893&lt;/STRONG&gt;&lt;SPAN&gt;, ErrorMessage: "Workspace or data source is read only"&lt;/SPAN&gt;&lt;SPAN&gt;. But the same code was working before with ArcObjecs to edit ArcSDE.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have thoroughly examined all possible causes for this issue and have ensured the following:&lt;/SPAN&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN&gt;The database connection has write access; I used the same connection properties and attempted to edit the Enterprise Geodatabase directly in ArcPro, and I was able to make edits.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I have tried different Enterprise Geodatabases, including MS SQL Server and PostgreSQL, and different versions, including 10.7 and 11.1.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;I have tested with an Enterprise Geodatabase connection on both a remote machine and a local machine.&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Therefore, I suspect that I may be overlooking something related to enabling&amp;nbsp;&lt;STRONG&gt;write-mode&lt;/STRONG&gt;&amp;nbsp;(making it not read-only) either within the Enterprise Geodatabase settings or during Workspace creation. Once this issue is resolved, I can use the same code that worked for the File Geodatabase connection with the Enterprise Geodatabase.&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Here is the code I am using to connect to and edit the Enterprise Geodatabase:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Set up the workspace factory for SQL Server with Database Authentication.
IWorkspaceFactory workspaceFactory = new SdeWorkspaceFactoryClass();

// Set the connection properties.
IPropertySet propertySet = new PropertySetClass();
propertySet.SetProperty("DATABASE", "_db_name_");
propertySet.SetProperty("INSTANCE", "sde:sqlserver:" + "_instance_");
propertySet.SetProperty("USER", "_user_");
propertySet.SetProperty("PASSWORD", "_password_");
propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS");
propertySet.SetProperty("VERSION", "dbo.DEFAULT");

IWorkspaceEdit workspaceEdit = null;

try
{
    // Open the connection.
    IWorkspace workspace = workspaceFactory.Open(propertySet, 0);

    if (workspace != null)
    {
        // Check if the workspace supports editing.
        workspaceEdit = (IWorkspaceEdit)workspace;
        if (!workspaceEdit.IsBeingEdited())
        {
            // Start an edit session.
            workspaceEdit.StartEditing(true); //&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; THIS IS WHERE I AM GETTING THE READ-ONLY ERROR &amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;
            workspaceEdit.StartEditOperation();
        }

        // Open the feature class you want to edit.
        IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workspace;
        IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("_feature_class_");

        // Create a query filter to find the specific feature to edit.
        IQueryFilter queryFilter = new QueryFilterClass();
        queryFilter.WhereClause = "YourField = 'YourValue'"; // Modify to match your criteria

        // Search for the feature.
        IFeatureCursor featureCursor = featureClass.Search(queryFilter, true);
        IFeature feature = featureCursor.NextFeature();

        if (feature != null)
        {
            // Modify the attributes of the feature as needed.
            feature.set_Value(featureClass.Fields.FindField("AttributeFieldName"), "NewValue");

            // Save the changes.
            feature.Store();
            workspaceEdit.StopEditOperation();
            workspaceEdit.StopEditing(true);

            Console.WriteLine("Feature edited successfully.");
        }
        else
        {
            Console.WriteLine("Feature not found.");
        }

        // Release resources.
        Marshal.ReleaseComObject(featureCursor);
        Marshal.ReleaseComObject(workspace);
    }
    else
    {
        Console.WriteLine("Failed to connect to the geodatabase.");
    }
}
catch (Exception ex)
{
    Console.WriteLine("Error: " + ex.Message);
}
finally
{
    // Make sure to stop the edit session in the finally block to release locks.
    if (workspaceEdit != null &amp;amp;&amp;amp; workspaceEdit.IsBeingEdited())
    {
        workspaceEdit.StopEditOperation();
        workspaceEdit.StopEditing(true);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;&lt;BR /&gt;Please advise how can I resolve the workspace read-only issue and resolve this problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Are there any special settings I have to do in ArcGIS Enterprise to get this editing work?&lt;/SPAN&gt;&lt;/P&gt;&lt;P data-unlink="true"&gt;&lt;SPAN&gt;Thank you for your time.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Sep 2023 16:55:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/enterprise-geodatabase-quot-startediting-quot/m-p/1328784#M20604</guid>
      <dc:creator>Vasu80</dc:creator>
      <dc:date>2023-09-14T16:55:50Z</dc:date>
    </item>
  </channel>
</rss>

