Save user input to database?

665
6
Jump to solution
02-04-2013 08:23 AM
ionarawilson1
Occasional Contributor III
I have one dropdown box that contains county names and one text input asking for number of acres. Does anybody have any examples or have any ideas on how I can save this information to a geodatabase once the user enter this information? It does not need to be shown on the map, just to be saved in a database. I have 10.1 Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
CaseyBentz
Occasional Contributor II
Do I have to create the webservice in Visual Studio? If so, I would prefer to use a geodatabase. Do you know of any examples? Thanks


For a web service, you would have to use visual studio or visual web developer express. 

If you have an SDE geodatabase, you can just create a table, register it with the geodatabase and register it as versioned.  Then add it to an MXD, publish it to ArcGIS Server with Feature Access enabled.  Then in your Flex application you can create a feature layer pointed at the service.  Then each time a user enters a value, you can create an object with the same fields as your table and add it to the graphic.attributes. 

 var inspections:FeatureLayer = new FeatureLayer("http://" + Model.instance.serverHost + "/ArcGIS/rest/services/Delivery/T_Inspections/FeatureServer/1");  inspections.addEventListener(FeatureLayerEvent.EDITS_COMPLETE, inspections_editsCompleteHandler); inspections.addEventListener(FeatureLayerEvent.EDITS_STARTING, inspections_editsStartingHandler); inspections.addEventListener(FaultEvent.FAULT, inspections_faultHandler);   var arr:Array = new Array(); for each(var item:Object in l_structures.selectedItems){  const inspection:Object = { GISONUMBER: item.GISONUMBER.toString(), INSPECTIONDATE: df_dateInspected.selectedDate.time, PATROLMANID: dd_patrolmanID.selectedItem.PATROLMANID.toString(), PATROLTYPE: dd_patrolType.selectedItem.TYPECODE.toString(), LINENUMBER: dd_lineNumber.selectedItem.ID.toString() };  const g:Graphic = new Graphic(null,null,inspection); arr.push(g); } inspections.applyEdits(arr, null, null, true);  

View solution in original post

0 Kudos
6 Replies
CaseyBentz
Occasional Contributor II
What kind of database do you have to store it in?  If it is an SDE database you could used ArcGIS Server and a Feature Layer.  If it is a non geodatabase database like SQLite or something like that, you could use a web service.
0 Kudos
ionarawilson1
Occasional Contributor III
Do I have to create the webservice in Visual Studio? If so, I would prefer to use a geodatabase. Do you know of any examples? But I dont want the user to add anything on the map. Just to enter the answer in the dropdown menu and text input and that would be saved in the database. Thanks
0 Kudos
CaseyBentz
Occasional Contributor II
Do I have to create the webservice in Visual Studio? If so, I would prefer to use a geodatabase. Do you know of any examples? Thanks


For a web service, you would have to use visual studio or visual web developer express. 

If you have an SDE geodatabase, you can just create a table, register it with the geodatabase and register it as versioned.  Then add it to an MXD, publish it to ArcGIS Server with Feature Access enabled.  Then in your Flex application you can create a feature layer pointed at the service.  Then each time a user enters a value, you can create an object with the same fields as your table and add it to the graphic.attributes. 

 var inspections:FeatureLayer = new FeatureLayer("http://" + Model.instance.serverHost + "/ArcGIS/rest/services/Delivery/T_Inspections/FeatureServer/1");  inspections.addEventListener(FeatureLayerEvent.EDITS_COMPLETE, inspections_editsCompleteHandler); inspections.addEventListener(FeatureLayerEvent.EDITS_STARTING, inspections_editsStartingHandler); inspections.addEventListener(FaultEvent.FAULT, inspections_faultHandler);   var arr:Array = new Array(); for each(var item:Object in l_structures.selectedItems){  const inspection:Object = { GISONUMBER: item.GISONUMBER.toString(), INSPECTIONDATE: df_dateInspected.selectedDate.time, PATROLMANID: dd_patrolmanID.selectedItem.PATROLMANID.toString(), PATROLTYPE: dd_patrolType.selectedItem.TYPECODE.toString(), LINENUMBER: dd_lineNumber.selectedItem.ID.toString() };  const g:Graphic = new Graphic(null,null,inspection); arr.push(g); } inspections.applyEdits(arr, null, null, true);  
0 Kudos
ionarawilson1
Occasional Contributor III
This seems the way to go Casey. Do you more examples or a more complete example that you can share? Thank you so much!
0 Kudos
CaseyBentz
Occasional Contributor II
This seems the way to go Casey. Do you more examples or a more complete example that you can share? Thank you so much!


This should get you on your way.  Just modify it to handle your workflow and data

private var inspections:FeatureLayer = new FeatureLayer("http://" + Model.instance.serverHost + "/ArcGIS/rest/services/Delivery/T_Inspections/FeatureServer/1");
   
      
   protected function init():void{
    inspections.addEventListener(FeatureLayerEvent.EDITS_COMPLETE, inspections_editsCompleteHandler);
    inspections.addEventListener(FeatureLayerEvent.EDITS_STARTING, inspections_editsStartingHandler);
    inspections.addEventListener(FaultEvent.FAULT, inspections_faultHandler);
   }
   
   /* function used to create inspection records */ 
   protected function btn_createInspection_clickHandler(event:MouseEvent):void{
     //Modify this portion to meet your requirements. 
      const inspection:Object = {
       GISONUMBER: item.GISONUMBER.toString(),
        INSPECTIONDATE: df_dateInspected.selectedDate.time,
        PATROLMANID: dd_patrolmanID.selectedItem.PATROLMANID.toString(),
        PATROLTYPE: dd_patrolType.selectedItem.TYPECODE.toString(),
        LINENUMBER: dd_lineNumber.selectedItem.ID.toString()
      };
      const g:Graphic = new Graphic(null,null,inspection);
      
     inspections.applyEdits(, null, null, true);
   }
   /* function used to handle when editing of inspections starts */
   protected function inspections_editsStartingHandler(event:FeatureLayerEvent):void{
    CursorManager.setBusyCursor();
   }
   /* function used to handle when editing of inspections completes */
   protected function inspections_editsCompleteHandler(event:FeatureLayerEvent):void{
    try{
     var flag:Boolean = true;
     var result:FeatureEditResult;
     
     
      for each(result in event.featureEditResults.addResults){
       if (!result.success)
        flag = false;
      }
      if(flag)
       Alert.show('Created - ' + event.featureEditResults.addResults.length.toString() + ' inspection records', 'info');
      else
       Alert.show('Some inspection records failed to create, rolling back edits','warning');
     
     CursorManager.removeBusyCursor();
    }catch(error:Error){
     CursorManager.removeBusyCursor();
    }
   }
   /* function to handle when editing inspections faults */
   protected function inspections_faultHandler(event:FaultEvent):void{
    Alert.show(event.fault.faultDetail, 'fault');
    CursorManager.removeBusyCursor();
   }

0 Kudos
ionarawilson1
Occasional Contributor III
Ok Casey! Thanks a lot! This will help me tremendously!
0 Kudos