Hi Everyone,
I am trying to use a list of keys, mukeys, to search for these mukey within the mukey field in the component table and create a query table, CompTable. I keep getting an error, field not found at the line, WhereClause within the QueryDef. How do I write the WhereClause correctly using a the mukeys list? Here is my script below:
//there is more script above, but I just included the script section related to this question.
using (Row row = rowCursor.Current)
{
mukeyCount++;
var mukey = Convert.ToString(row["MUKEY"]);
mukeys.Add(mukey);
}
...
QueryDef queryDef = new QueryDef
{
Tables = "component",
WhereClause = "mukey= mukeys[mukeycount]", //error occurs here
SubFields = "component.cokey,component.mukey,component.comppct_r"
};
QueryTableDescription queryTableDescription = new QueryTableDescription(queryDef)
{
Name = "CompTable",
PrimaryKeys = geodatabase.GetSQLSyntax().QualifyColumnName("component", "cokey")
};
Table queryTable = geodatabase.OpenQueryTable(queryTableDescription);
Thanks everyone!