Select to view content in your preferred language

ArcObjects EDITING: "Underlying DBMS error" issue inserting Double data type

2730
7
07-12-2010 12:11 PM
shawndeutch
Occasional Contributor
I am trying to insert data into a feature class field called "DACOUNCIL".  You can see the code below. 

            workspaceEdit = aoDataset.Workspace as ESRI.ArcGIS.Geodatabase.IWorkspaceEdit;
            if (!(workspaceEdit.IsBeingEdited()))
            {
                workspaceEdit.StartEditing(false);

                adfSelectedParcelGeometry = SelectedParcelsGraphicsLayer.GeometryFromRow(SelectedParcelsGraphicsLayer.Rows[0]);
              
                aoSelectedParcelGeometry = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.ToIGeometry(adfSelectedParcelGeometry, serverContext);

                // Create a feature and set its geometry and attributes
                ESRI.ArcGIS.Geodatabase.IFeature feature;
                feature = featureClass.CreateFeature();
                feature.Shape = aoSelectedParcelGeometry;

//THIS WORKS
                Double dblAreaFeet = (Double)SelectedParcelsGraphicsLayer.Rows[0]["AREA_FEET"];
                feature.set_Value(featureClass.FindField("AREA_FEET"), dblAreaFeet);

//THIS DOES NOT WORK
                Double dbldaCouncil = (Double)SelectedParcelsGraphicsLayer.Rows[0]["DACOUNCIL"];
                feature.set_Value(featureClass.FindField("COUNCIL_DISTRICT"), dbldaCouncil);

//THIS DOES NOT WORK
                //feature.set_Value(featureClass.FindField("DACOUNCIL"), (Double)14.0);
                
                
                feature.set_Value(featureClass.FindField("DEMOLITION_ID"), "11");
             
                string strNotes = "shawn " + DateTime.Now;
                feature.set_Value(featureClass.FindField("NOTES"), strNotes);

                // Commit the new feature to the database
                feature.Store();

                workspaceEdit.StopEditing(true);

                // Release the current server context
                serverContext.ReleaseContext();
            }
        }



It works find on most data.  It has a problem with a field that in SQL Server 2005 is listed as being Numeric - precision 10; scale 0.  Some how I think the scale 0 is causing problems.

1) I can insert in other fields that are double - see area feet above.
2) The exception error is always thrown on the .store operation.
3) Checking the DACOUNCIL data type using IFields  as below it returns esriFieldTypeDouble.
4) ArcCatalog lists the data type as being Double
5) I can edit the field in ArcMap
6) I can edit the field in SQL Server

ESRI.ArcGIS.Geodatabase.IFields fields = featureClass.Fields;
 string strFieldType = fields.get_Field(i).Type.ToString();


Here is the error message I get:

{"Underlying DBMS error[Microsoft SQL Native Client: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.][gisVector.GISLOADER.CCS_DemolitionParcels]"}
0 Kudos
7 Replies
AlagappanAL
Deactivated User
Hi,

         One thing that i can notice is that the following lines are missing which I feel important for editing the featureclasses via code. Could you please try out this.

workspaceEdit.StartEditOpeation; (after workspaceEdit.StartEditing(false);)
workspaceEdit.StopEditOperation; (before workspaceEdit.StopEditing(true);)


Regards
Alagappan
0 Kudos
shawndeutch
Occasional Contributor
Those two lines are in the code I just did not include them in code I posted.

I am able to create a feature and add attributes to that feature successfully in most all cases.

The issue seems to be with a field that has a data type of Double precision 10 with a scale of 0.

I get an exception when I try to store that back to SDE.

I wonder if it is a memory issue since I get a COM exception error. - see attached stack trace
0 Kudos
KirkKuykendall
Deactivated User
The code below works for me with SqlServer 2008 arcgis 9.3.1 sp1.
DField is precision 10 scale 0.

Do you get the same error when running from arcmap (without arcgis server?)

Maybe it's a dbms driver issue?

/// <summary>
/// Occurs when this command is clicked
/// </summary>
public override void OnClick()
{
    try
    {
        IMap map = ((IMxDocument)m_application.Document).FocusMap;
        IEnvelope env = ((IActiveView)map).Extent;
        env.Expand(0.5, 0.5, true);
        ISegmentCollection sc = new PolygonClass();
        sc.SetRectangle(env);

        IFeatureLayer fLayer = map.get_Layer(0) as IFeatureLayer;
        IWorkspace ws = ((IDataset)fLayer.FeatureClass).Workspace;
        TestDoubleUpdate(ws,(IPolygon)sc);
        ((IActiveView)map).Refresh();
    }
    catch (Exception ex)
    {
        Debug.Print(ex.Message);
    }
}

public static void TestDoubleUpdate(IWorkspace ws, IPolygon polygon)
{
    IWorkspaceEdit wse = (IWorkspaceEdit)ws;
    IFeatureClass fc = ((IFeatureWorkspace)ws).OpenFeatureClass("mydb.DBO.TestPolys");
    wse.StartEditing(false);
    wse.StartEditOperation();
    IFeature feat = fc.CreateFeature();
    feat.Shape = polygon;
    feat.set_Value(feat.Fields.FindField("DField"),(Double)14.0);
    feat.Store();
    wse.StopEditOperation();
    wse.StopEditing(true);
}


Update: is the column listed in the sde_column_registry table?
0 Kudos
shawndeutch
Occasional Contributor
I am on 9.3.1 sp1.  I am working with ArcGIS Server, SOAP, and ArcObjects

What is strange is looking at ArcCatalog behavior vs SQL Server.  If I edit in ArcMap I do not get the errors.

ArcCatalog will not let you create a Double with precision <= 9 and scale 0 - it says invalid column.
ArcCatalog defaults to Double with precision 38 and scale 8 if you do not enter them

If I add scale of 1 it seems happy with what ever precision i set.  I tested up to precision 15, scale 1.

This is an interesting article on a comparison of the datatypes in SQL server, ArcGIS, and SDE

http://help.arcgis.com/en/arcgisserver/10.0/help/arcgis_server_dotnet_help/index.html#/A_comparison_...

look down at the 5th row

SDE: SE_INT64_TYPE
SQL: BIGINT or NUMERIC (precision < 19, scale = 0)
ARCGIS: na

NOTES: The server configuration parameter INT64TYPES must be TRUE to create columns with this data type.
0 Kudos
KirkKuykendall
Deactivated User
More config info:
I'm running SqlServer 32 bit (x86) on Vista 64 with INT64TYPES false.

Why would you want to use a scale of 0 instead of just using an integer field?

Anyway, what is your INT64TYPES value set to?

By chance did add the DACOUNCIL field using SSMS (instead of ArcCatalog) ?

When you look at the DACOUNCIL column in SSMS, what does it show?
0 Kudos
shawndeutch
Occasional Contributor
I had originally added the column in SSMS and was playing with it there.

It was set as numeric(10,0) in SQLServer 2005.  The only reason i did so was to match the source dataset I am pulling attributes from.  Someone else set up the schema for that one.  Why it was set up as a numeric(10,0) I am not sure since the data in the column is integer and would not be a value greater than 15. 

Sooo in the end I am just going to set my featureclass to have the correct data type of integer.

I was just surprised by the error I was getting and wanted to figure out what was causing it if I could as I learn more about the API in doing so.

thanks for your help
0 Kudos
KirkKuykendall
Deactivated User
I had originally added the column in SSMS and was playing with it there.


If you add a column using arccatalog, it will add a row to the sde_column_registry table - but not if you add it using SSMS.

Perhaps the way arcgis converts column values to IField types depends on whether the field is listed in the column registry.
0 Kudos