2

I use ArcGIS for Server. I have all of my data for my feature layer on that database. The point is being added by coordinates, but it is not saving to the database. I am getting the error "An error occurred in the database" in my server logs.

My code is below.

Here is the log:

<?xml version="1.0" encoding="utf-8" ?>
<Msg time='2014-03-31T11:06:05,468' type='SEVERE' code='17000' target='Calvert_City_Test.MapServer' methodName='GraphicFeatureLayer.Add' machine='ARCGIS-PC' process='696' thread='3204' user='anonymous' >A database error occurred.</Msg>
<Msg time='2014-03-31T11:06:05,810' type='SEVERE' code='17000' target='Calvert_City_Test.MapServer' methodName='GraphicFeatureServer.HandleREST_ApplyEditsOperation' machine='ARCGIS-PC' process='696' thread='3204' user='anonymous' >A database error occurred.</Msg>
<Msg time='2014-03-31T11:08:49,895' type='SEVERE' code='17000' target='Calvert_City_Test.MapServer' methodName='GraphicFeatureLayer.Add' machine='ARCGIS-PC' process='696' thread='3204' user='anonymous' >A database error occurred.</Msg>
<Msg time='2014-03-31T11:08:49,965' type='SEVERE' code='17000' target='Calvert_City_Test.MapServer' methodName='GraphicFeatureServer.HandleREST_ApplyEditsOperation' machine='ARCGIS-PC' process='696' thread='3204' user='anonymous' >A database error occurred.</Msg>

Each time I add it produces two error messages. This is showing me trying to add a feature two separate times.

Here is my XAML:

  <esri:FeatureLayer ID="Meters" 
                    Url="http://xx.xx.xxx.xx/arcgis/rest/services/Calvert_City_Test/FeatureServer/2"
                    MouseLeftButtonUp="FeatureLayer_MouseLeftButtonUp" 
                    DisableClientCaching="True"
                    OnDemandCacheSize="0"
                    Mode="OnDemand"
                    AutoSave="False"

C#:

 private void CorrectInformationButton_Click(object sender, RoutedEventArgs e)
        {
            CheckAddedPoint.Visibility = Visibility.Collapsed;
            OptionsPortal.Visibility = Visibility.Visible;

            FeatureLayer featurelayer = MyMap.Layers["Meters"] as FeatureLayer;

            double latitude = Convert.ToDouble(addLat);
            double longitude = Convert.ToDouble(addLong);

            Graphic graphic = new Graphic()
            {
                Geometry = _mercator.FromGeographic(new MapPoint(longitude, latitude)),
                Symbol = LayoutRoot.Resources["DefaultMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol
            };

        graphic.Attributes["OBJECTID"] = 244;
        graphic.Attributes["PWSID"] = "55555";
        graphic.Attributes["CIS_METR"] = addAccount;
        graphic.Attributes["CUSTYPE"] = " ";
        graphic.Attributes["SIZE"] = Convert.ToDouble(5);
        graphic.Attributes["TYPE"] = " ";
        graphic.Attributes["OTHTYPE"] = " ";
        graphic.Attributes["MANUF"] = " ";
        graphic.Attributes["MODEL"] = " ";
        graphic.Attributes["YEAR"] = " ";
        graphic.Attributes["TESTDATE"] = " ";
        graphic.Attributes["MASTER"] = " ";
        graphic.Attributes["MBOX"] = " ";
        graphic.Attributes["MBOXTYPE"] = " ";
        graphic.Attributes["PLACE"] = " ";
        graphic.Attributes["STR"] = addStreet;
        graphic.Attributes["CITY"] = addcity;
        graphic.Attributes["COUNTY"] = " ";
        graphic.Attributes["AGENCY_CON"] = " ";
        graphic.Attributes["CONTACT"] = " ";
        graphic.Attributes["LAST_UPDT"] = " ";
        graphic.Attributes["XY_SOURCE"] = " ";
        graphic.Attributes["XY_ISSUES"] = " ";
        graphic.Attributes["COMMENTS"] = addName;
        graphic.Attributes["SHAPE"] = null;


            featurelayer.Graphics.Add(graphic);
            featurelayer.SaveEdits();
        }
3
  • More Info: If I use the editing widget, everything works perfectly and the data is saved. However, I need to be able to add though code.
    – JLott
    Commented Mar 31, 2014 at 16:23
  • Looks like you're trying to access the database as anonymous. Are you authenticating through the editing widget somehow?
    – Mintx
    Commented Mar 31, 2014 at 21:07
  • I don't believe so. I seriously just added it to the XAML and it worked haha.
    – JLott
    Commented Apr 1, 2014 at 15:54

1 Answer 1

3

I finally figured out this issue after struggling forever. So I will let those who also may be having problems know what I did to find my problem.

1.) Do not assign a different symbol to the graphic. Just let it use the graphic that is associated with the feature layer. This will happen automatically without any additional code.

2.) Do not assign the shape as null.

3.) This was my main issue. I was assigning every attribute some sort of value. In the attributes list I was looking at, it did not show two fields. Those fields were getting a null value which is the main reason it could not save. It was not a nullable field. Here is where you need to go to see the fields that need to be assigned:

Go to you ArcGIS for Server Click on the site you want Go to Capabilities Click on Feature Access (the word not check box) Click on the REST Link Click on the layer you want There will be a list of all of the fields and their types.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.