テーブルからレコードを読み取るために、次のコードを (Arcobjcts を使用して C# .net で) 作成しました。
ITable table =featureWorkspace1.OpenTable(featureClass1.AliasName);
List<String> list2 = new List<String>();
ITableSelection tableSelection = table as ITableSelection;
ISelectionSet2 selectionSet = tableSelection.SelectionSet as ISelectionSet2;
ICursor Cursor = null;
IFeatureCursor featureCursor = Cursor as IFeatureCursor;
selectionSet.Search(null, true, out Cursor);
int fieldIndex = featureCursor.Fields.FindField(champ);
list2.Add(fieldIndex.ToString());
this.listBox2.DataSource = list2;
しかし、エラーが発生します:
オブジェクトのインスタンスに設定されていないオブジェクト参照
また、私は試しました:
IQueryFilter queryFilter = new QueryFilterClass();
queryFilter.WhereClause = " champ <> '' ";
ICursor Cursor = table.Search(queryFilter,true);
IRow city = Cursor.NextRow();
while (city != null)
{
list2.Add((String)(city.Value[fieldIndex].ToString()));
city = Cursor.NextRow();
}
this.listBox2.DataSource = list2;
エラーは次のとおりです。
HRESULT 0x80040358 からの例外
これら2つの問題のうちの1つを修正する方法を教えてください。