Query FGDB Feature Class from C#.NET Application

Discussion created by shaun_weston-eagle-co-nz-esridist on Apr 17, 2012
Latest reply on Apr 18, 2012 by kenbuja
I've never really done any ArcObjects development before and just looking for some advice. I have built a C#.NET application and I want that to be able to read the attribute data from a feature class in a file geodatabase and just wondering exactly how to do that?

Would using this example I found be the best way to go?

I'm not exactly sure how to define the geodatabase and the table in this though?

            // 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.
            IQueryFilterDefinition queryFilterDef = (IQueryFilterDefinition)queryFilter;
            queryFilterDef.PostfixClause = "ORDER BY NAME";

            // Output the returned names and addresses.
            int nameIndex = table.FindField("NAME");
            int addressIndex = table.FindField("ADDRESS");
            using (ComReleaser comReleaser = new ComReleaser())
                ICursor cursor = table.Search(queryFilter, true);
                IRow row = null;
                while ((row = cursor.NextRow()) != null)
                    String name = Convert.ToString(row.get_Value(nameIndex));
                    String address = Convert.ToString(row.get_Value(addressIndex));
                    Console.WriteLine("{0} - {1}", name, address);