Select to view content in your preferred language

Geodatabase exception when querying data

912
6
Jump to solution
05-15-2025 03:49 AM
BarbaraSchneider2
Frequent Contributor

We are doing stereo aerial image interpretation in ImageAnalyst. Our stereo interpreter receives the following error message about every hour: A geodatabase exception has occurred. This happens in the following function, when executing featLayer.Search(queryFilter):

public static async Task<Feature> GetFeatureAsync(FeatureLayer featLayer, string whereClause)
{		
	try
	{
		Feature feature = await QueuedTask.Run(() =>
		{
			// Query the FC 
			QueryFilter queryFilter = new QueryFilter();
			queryFilter.WhereClause = whereClause;

            using RowCursor rowCursor = featLayer.Search(queryFilter);
			if (rowCursor.MoveNext())
			{
				// Get feature
				Row row = rowCursor.Current;
				feature = row as Feature;
				return feature;
			}
			return null;
		});
		return feature;
	}
	catch (Exception ex)
	{
		ProPopupMessage.Error(MiscUtils.GetMethodName(), ex.Message);
		return null;
	}
}

I would like to explain a bit in more detail what the stereo interpreter is doing. He is recording woody plant coverage in every square of a biotope object:

BarbaraSchneider2_0-1747305733025.png

The workflow looks as follows:

  1. He selects a square on the stereo map
  2. In the code, the ObjectID of this square (polygon) is retrieved. The ObjectID corresponds to the ID of the point feature.
  3. The above function (GetFeatureAsync()) is called to get the corresponding point feature. The whereClause is "ID=" + objectID.
  4. After the error has occurred, ArcGIS Pro has to be restarted because the same errors occurs again and again when selecting a polygon.

I doublechecked, the objectID really exists when the error occurs. What could be the cause of the problem?

Should I try to search the feature class instead of the feature layer?

0 Kudos
1 Solution

Accepted Solutions
SumitMishra_016
Frequent Contributor

Yes — you should switch to searching on the FeatureClass instead of the FeatureLayer, as it's more robust and avoids rendering-related issues.

public static async Task<Feature> GetFeatureAsync(FeatureLayer featLayer, string whereClause)
{
	try
	{
		Feature feature = await QueuedTask.Run(() =>
		{
			// Access the FeatureClass directly
			FeatureClass featureClass = featLayer.GetFeatureClass();
			if (featureClass == null)
				return null;

			QueryFilter queryFilter = new QueryFilter
			{
				WhereClause = whereClause
			};

			using (RowCursor rowCursor = featureClass.Search(queryFilter, false))
			{
				if (rowCursor.MoveNext())
				{
					return rowCursor.Current as Feature;
				}
			}
			return null;
		});

		return feature;
	}
	catch (Exception ex)
	{
		
		return null;
	}
}

 

View solution in original post

0 Kudos
6 Replies
SumitMishra_016
Frequent Contributor

Yes — you should switch to searching on the FeatureClass instead of the FeatureLayer, as it's more robust and avoids rendering-related issues.

public static async Task<Feature> GetFeatureAsync(FeatureLayer featLayer, string whereClause)
{
	try
	{
		Feature feature = await QueuedTask.Run(() =>
		{
			// Access the FeatureClass directly
			FeatureClass featureClass = featLayer.GetFeatureClass();
			if (featureClass == null)
				return null;

			QueryFilter queryFilter = new QueryFilter
			{
				WhereClause = whereClause
			};

			using (RowCursor rowCursor = featureClass.Search(queryFilter, false))
			{
				if (rowCursor.MoveNext())
				{
					return rowCursor.Current as Feature;
				}
			}
			return null;
		});

		return feature;
	}
	catch (Exception ex)
	{
		
		return null;
	}
}

 

0 Kudos
BarbaraSchneider2
Frequent Contributor

Thank you, I will do this! I will let you know in a couple of days if the stereo interpreter gets less errors.

0 Kudos
RichardDaniels
Honored Contributor

Also, think about where on the network your Geodatabase is being saved. Recall that Geodatabases on OneDrive 'are not supported by ESRI'. The data transfer delay associated with OneDrive and other Cloude storage solutions dependent on network traffic (and any dropped packets) from your desk all the way to the server in (wherever that is at ;-).

0 Kudos
BarbaraSchneider2
Frequent Contributor

Our geodatabase is a file geodatabase on a local disk.

I've talked to our stereo interpreter. The error now only occurs about once per day, not every hour.

0 Kudos
BarbaraSchneider2
Frequent Contributor

Unfortunately, problem is not solved yet. The stereo interpreter is now working faster and the error appears about every hour. We have migrated the application from ArcGIS to ArcGIS Pro. We did exactly the same thing in ArcGIS, and there was no error! 

What makes things worse, is the fact that after having restarted ArcGIS Pro after the error, the buttons in the ribbon only get activated after about 20 minutes. So as a workaround, we recreate the .aprx.

I think that this is a bug that has to be fixed by ESRI staff. I could solve this problem differently by creating a relationship between the square FC and the point FC instead of querying the point FC.

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

@BarbaraSchneider2 , I am not familiar with the migration or stereo components, but you can establish a relationship between the specific rows of the squareFC and the pointFC using the CreateRelationship method.

Sample code snippets

0 Kudos