How to run the query in FGDB using ArcGIS Pro SDK.Net

517
3
Jump to solution
05-30-2022 11:15 PM
by Anonymous User
Not applicable

Hi,

I'm using LabelBuilder to assign labels to the events posted on the line feature class, and there's a button for verifying the label. So, for the SDE database, I implemented it using the code below, but I'm not sure how we can do it in FGDB.

ShabinaBano_0-1653977314690.png

For FGDB I tried using QueryDef but getting the Error : SQL statement invalid 

***********************************************************************************

string[] message = TxtBoxDescription.Split('+');
Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(MapGlobal.Instance.databaseConnection.EventCatalogPath)));
{

QueryDef queryFilter = new QueryDef
{

PrefixClause = message[0],
Tables = TableName,

};
using (RowCursor cursor = fileGeodatabase.Evaluate(queryFilter, false))
{

while (cursor.MoveNext())
{
using (Row row = cursor.Current)
{

 // code here

}

}

***************************************************************************************

Could someone please assist me by providing a code snippet for the same?

Thanks in advance!

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi,

I used the code below, and it worked as expected.

***************************************************

Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(MapGlobal.Instance.databaseConnection.EventCatalogPath)));
{
QueryDef queryDef = new QueryDef
{
Tables = TableName,
SubFields = SelectedColumnName,


};

using (RowCursor cursor = fileGeodatabase.Evaluate(queryDef))
{

while (cursor.MoveNext())
{
using (Row row = cursor.Current)
{
// code here
}
}

*********************

Thanks!

View solution in original post

0 Kudos
3 Replies
Aashis
by Esri Contributor
Esri Contributor

Sample Pro snippets

QueryDef concepts 

An SQL prefix clause supports NoneDISTINCT, ALL, and TOP. An SQL postfix clause supports NoneORDER BY, and GROUP BY

TOP is only supported by SQL Server databases.

 

0 Kudos
by Anonymous User
Not applicable

Hi,

I used the code below, and it worked as expected.

***************************************************

Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(MapGlobal.Instance.databaseConnection.EventCatalogPath)));
{
QueryDef queryDef = new QueryDef
{
Tables = TableName,
SubFields = SelectedColumnName,


};

using (RowCursor cursor = fileGeodatabase.Evaluate(queryDef))
{

while (cursor.MoveNext())
{
using (Row row = cursor.Current)
{
// code here
}
}

*********************

Thanks!

0 Kudos
Aashis
by Esri Contributor
Esri Contributor

Glad to be of help.

0 Kudos