我在我的C#代碼中迭代DataTable。我嘗試使用使用名爲「行」行命名爲「列名」一欄來獲得內容 -列abc不屬於表?
object value = row["ColumnName"];
我得到這個錯誤 -
Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Column 'FULL_COUNT' does not belong to table . at System.Data.DataRow.GetDataColumn(String columnName)
這怎麼可能?我的SQL查詢/結果集有一個名稱的列,查詢甚至運行在管理工作室。
如何解決此錯誤?
你能發表更多的代碼嗎? – Szymon
請說明如何查詢數據庫以開始。您可能還想查看錶格中的所有列以確定*已被選中。 –
@JonSkeet - 好的。我將需要一些時間在示例表中複製問題。很快就會做到。 – Steam