Select to view content in your preferred language

Get Attribute Value from selection VB.net

868
1
12-15-2010 12:33 PM
MatthewPeterson
Emerging Contributor
I am looking for some help retrieving specific attribute values from a shapefile.

I want to search my attributes based on state name, and then populate a textbox with the states population, but I am having trouble figuring out how to access/retrieve the data in my attribute table.

Any help/pointers would be appreciated.
0 Kudos
1 Reply
Venkata_RaoTammineni
Regular Contributor
I am looking for some help retrieving specific attribute values from a shapefile.

I want to search my attributes based on state name, and then populate a textbox with the states population, but I am having trouble figuring out how to access/retrieve the data in my attribute table.

Any help/pointers would be appreciated.



Use IQueryFilter to query the data.... something like this


public ICursor GetRestaurants(ITable table)
{
    // Create the query filter.
    IQueryFilter queryFilter = new QueryFilterClass();

    // Select the fields to be returned - the name and address of the businesses.
    queryFilter.SubFields = "NAME, ADDRESS";

    // Set the filter to return only restaurants.
    queryFilter.WhereClause = "TYPE = 'Restaurant'";


    // Use the PostfixClause to alphabetically order the set by name. Although this
    // has no effect on a File geodatabase, this will work for Personal and SDE
    // geodatabases.
    IQueryFilterDefinition queryFilterDef = (IQueryFilterDefinition)queryFilter;
    queryFilterDef.PostfixClause = "ORDER BY NAME";

    ICursor cursor = table.Search(queryFilter, true);
    return cursor;
}
0 Kudos