I am wondering how I can fix this WhereClause? Everything seems to work, except for the query. Thanks for your help!
QueuedTask.Run(() =>
{
string mKey = "462409";
var ckeys = new string[3] { "19605542","19605543","19605707" };
using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(inPath))))
using (var HzTable = geodatabase.OpenDataset<Table>("TableName"))
{
foreach (var Ckey in ckeyList)
{
QueryFilter qf = new QueryFilter()
{
WhereClause = $@"ckey = {Ckey}",
};
using (var rowCursor = HzTable.Search(qf)) //error here
{
while (rowCursor.MoveNext())
{
using (Row row = rowCursor.Current)
{
Calculations performed here...etc.
If you're filtering on a string field, you need to enclose the variable in quotes
WhereClause = $@"ckey = '{Ckey}'",
Depending on the datatype of ckey field you might have to change your syntax so that:
WhereClause = $@"ckey = {Ckey}",
could turn into this:
WhereClause = $@"ckey = '{Ckey}'",
Needless to say the field 'ckey' must exists in the table "TableName"