我的DataSet中的第一列填充了数字1-4。我希望能够根据内部数字过滤并将我的DataSet拆分为四个不同的DataSet。
例如,如果我有:
Dim ds as New DataSet
我想将ds分成四个不同的DataSet(同时保留原始的ds)。为了实现这个目标:
Dim ds1 as New DataSet 'contains all rows that have the number 1 in the first column
Dim ds2 as New DataSet 'contains all rows that have the number 2 in the first column
Dim ds3 as New DataSet 'contains all rows that have the number 3 in the first column
Dim ds4 as New DataSet 'contains all rows that have the number 4 in the first column
总共有大约1,000行,因此需要以最有效和最快的方式进行。有人可以帮忙吗?
根据Plutonix的建议:
Dim newDV As New DataView
newDV = ds.Tables("Table1").DefaultView
newDV.RowFilter = "COLUMNONENAME = 2"
当我把它放入try / catch时,它会捕获一个错误,但是当它不在try / catch中时,没有错误。奇怪的。 所以现在我尝试显示信息:
txtBox1.Text = Convert.ToString(newDV(0)("COLUMNONENAME"))
这应该显示第一个在COLUMNONENAME中具有数字2的条目,但它仍然显示DataSet的第一个条目,而不管COLUMNONENAME中的条目是什么。