2
var query = from row in testDBDataSet.TestTable
where !row.Name.Equals("test")
select row;
TestDBDataSet.TestTableDataTable tempTable =
(TestDBDataSet.TestTableDataTable) query.CopyToDataTable<TestDBDataSet.TestTableRow>();
TestTableTableAdapter.Fill(tempTable);
運行此代碼時,出現錯誤InvalidOperationException was unhandled - 源代碼中未包含DataRows。關於定製DataTable的LINQ查詢
那裏肯定有符合那個標準的數據,我做錯了什麼?我從SQL Server 2008 R2數據庫中選擇一個表格作爲DataSource
作爲DataGridView
。我希望它只顯示符合條件的特定行。
當我註釋掉where !row.Name.Equals("test")
所以你的查詢是空的? –
我將首先使用SQL Profiler來查看服務器上正在運行的內容,然後查看您是否可以從那裏確定爲什麼沒有返回行。 – BlackICE
TestTable是一個DataTable嗎? – Kaf