Processing errors generated when exceptions are interrupted during SDE data editing

Source: Internet
Author: User

ArcSDE is often interrupted in the process of data import or editing. Some of the factors (debugging interrupted) are also non-human factors (Network disconnection). The direct consequence after the interruption is that the program is re-executed incorrectly. The error code is-2147216556. The error explanation is fdo_e_objectclass_requires_an_edit_session.

It is usually depressing to write the program because startedit has been called in the program and the program has started the session editing process. The above error is also reported. In fact, the spatial index of ArcSDE has been damaged during the interruption and needs to be re-computed. During the data editing process, newly added or modified records will automatically modify the index of the current element class. If an error occurs in the program, the modification process of spatial indexes cannot be completed. As a result, invalid spatial indexes are accidentally used during the data re-editing process. During the editing process, the error-2147216556 is reported.

The solution is to re-calculate the spatial index. There are many ways to recalculate spatial indexes in ArcGIS. You can use the index edit or re-calculate function under the index item on the arccatalog attribute page. Or use the re-computing index tool under GP. You can even use the code to modify it. In the help of ArcObjects, you can refer to the following methods:

// Passing zero values for all three double parameters recalculates the spatial index with <br/> // acceptable (but not necessarily optimal) values. <br/> Public void rebuildspatialindex (ifeatureclass featureclass, double gridonesize, <br/> double gridtwosize, double gridthreesize) <br/> {<br/> // get an enumerator for indexes based on the shape field. <br/> iindexes indexes = featureclass. indexes; <B R/> string shapefieldname = featureclass. shapefieldname; <br/> ienumindex enumindex = indexes. findindexesbyfieldname (shapefieldname); <br/> enumindex. reset (); </P> <p> // get the index based on the shape field (shocould only be one) and delete it. <br/> iindex Index = enumindex. next (); <br/> If (index! = NULL) <br/>{< br/> featureclass. deleteindex (INDEX); <br/>}</P> <p> // clone the shape field from the feature class. <br/> int shapefieldindex = featureclass. findfield (shapefieldname); <br/> ifields fields = featureclass. fields; <br/> ifield sourcefield = fields. get_field (shapefieldindex); <br/> iclone sourcefieldclone = (iclone) sourcefield; <br/> iclone targetfieldclone = sourcefieldclone. clone (); <br/> ifield targetfield = (ifield) targetfieldclone; </P> <p> // open the geometry definition from the cloned field and modify it. <br/> igeometrydef geometrydef = targetfield. geometrydef; <br/> igeometrydefedit geometrydefedit = (igeometrydefedit) geometrydef; <br/> geometrydefedit. gridcount_2 = 3; <br/> geometrydefedit. set_gridsize (0, gridonesize); <br/> geometrydefedit. set_gridsize (1, gridtwosize); <br/> geometrydefedit. set_gridsize (2, gridthreesize); </P> <p> // create a spatial index and set the required attributes. <br/> iindex newindex = new indexclass (); <br/> iindexedit newindexedit = (iindexedit) newindex; <br/> newindexedit. name_2 = shapefieldname + "_ Index"; <br/> newindexedit. isascending_2 = true; <br/> newindexedit. isunique_2 = false; </P> <p> // create a fields collection and assign it to the new index. <br/> ifields newindexfields = new fieldsclass (); <br/> ifieldsedit newindexfieldsedit = (ifieldsedit) newindexfields; <br/> newindexfieldsedit. addfield (targetfield); <br/> newindexedit. fields_2 = newindexfields; </P> <p> // Add the spatial index back into the feature class. <br/> featureclass. addindex (newindex); <br/>}</P> <p>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.