Question

In ArcGIS10/VB2010 I am using the IQueryFilter interface to hit a shapefile and get back some records. It works great but am having trouble figuring out how to get results back in an order as input by the user. The order is critical as the user will expect a graphic to be drawn between these airports as they input them which can be in any order. The user inputs airports in a listbox and I take that and create a WHERE clause out of it. By default the recordset returned is in alphabetical order which will not work here as the user needs the results back in the order they input.

Dim pQryFltr As IQueryFilter = New QueryFilter
pQryFltr.WhereClause = "APT LIKE 'DFW' OR APT LIKE 'STL' OR APT LIKE 'ORD'"

results come back as

DFW
ORD
STL

The only thing I can think of is to step through each listbox item and do individual queries on each item and then add that to my results. But that seems rather inefficient for a large number of inputs.

Was it helpful?

Solution 2

I opted to go with a very simple solution. Since the user will input at most 20 airports then I take each airport and do individual queries and just keep adding the returned records to my grid. That way they are added to the grid as they are input in the list.

OTHER TIPS

In ArcGIS 10 and up, the IQueryDef2 interface has a .PostfixClause that will allow for ORDER BY. This will only work for geodatabase data sources though.

For shapefiles, you need to use the ITableSort interface: Esri ITableSort

An example of how to use it is here: ITableSort Example

If you are looking to sort the shapefile in the order the features were created then you'll want to sort by FID.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top