Are you assuming that there is a row that is unique?
I have looked through the datatable that was returned by the query, and only the we created was there and there is not a row that is unique. I realize we should have some sort of ID row, and I normally would if I was linking my shapes to an external datasource. however when I'm working directly with a shapefile and not linking it externally we don't always create a unique identifier row, as as far as my understanding of shape files go, there is a a link to the attribute data based on the shapes index in the shape file and the row number in the attribute file.
Having said that, I realized that its not actually necessary to use a unique identifier row to link to the data, as I can actually use the column I am searching. Below is the modified version of your code
public static Collection<feature> QueryFeatures(ShapeFileFeatureLayer layer, string ColumnName, string Criteria) { string strSQL = string.Empty; string strCriteria = string.Empty; if (Criteria.Contains("*")) { strCriteria = Criteria.Replace("*", "%"); strSQL = String.Format("SELECT * FROM {0} WHERE {1} LIKE '{2}'", Path.GetFileNameWithoutExtension(layer.ShapePathFileName), ColumnName, strCriteria); } else { strCriteria = Criteria; strSQL = string.Format("SELECT * FROM {0} WHERE {1} = '{2}'", Path.GetFileNameWithoutExtension(layer.ShapePathFileName), ColumnName, strCriteria); } layer.Open(); DataTable dataTable = layer.QueryTools.ExecuteQuery(strSQL); layer.Close(); Collection<feature> returnFeatures = new Collection<feature>(); if (dataTable.Rows.Count > 0) { foreach (DataRow dataRow in dataTable.Rows) { string recId = dataRow[ColumnName].ToString(); Collection<feature> tempFeatures = layer.FeatureSource.GetFeaturesByColumnValue(ColumnName, recId); if (tempFeatures.Count != 0) { foreach (Feature featureResults in tempFeatures) if (!returnFeatures.Contains<feature>(featureResults)) returnFeatures.Add(featureResults); } } } return returnFeatures; }
I realize this is more modified for my solution, however if you are looking at wrapping a similar sort of query function into map suite, you may want to keep in mind that there is not necessarily a unique column created in the attribute table.
I appologize if I am incorrect in this statement.
Anyway. Thanks for the code above though. This should solve my problem.