V
Versteijn
Hello all,
I have a method that constructs a dataset and sorts table 0 in it
through Table(0).DefaultView.Sort. I need to find a certain row in
this sorted dataview, and have the following code.
My problem is that I get an exception on the call to Find() telling me
it needs 2 values, but gets 3. While testing of my code shows that it
only provides 2 values.
Anyone has an idea? If there's an easier way to get what I want that
would be even greater! Thanks in advance.
The exception: Expecting 2 value(s) for the key being indexed, but
received 3 value(s).
My code:
Dim ds As DataSet = products.CreateDataSet(context, 2)
Dim dr As DataRow = ds.Tables(0).Rows.Find(ModelID)
Dim dv As DataView = ds.Tables(0).DefaultView
Dim k() As String = dv.Sort.Split(",")
Dim keys(k.Length) As Object
For i As Integer = 0 To k.Length - 1
Dim s As String = k(i)
s = s.Replace("DESC", "")
s = s.Trim()
If s.Length > 0 Then
keys(i) = dr(s)
End If
Next
Dim index As Integer = dv.Find(keys)
I have a method that constructs a dataset and sorts table 0 in it
through Table(0).DefaultView.Sort. I need to find a certain row in
this sorted dataview, and have the following code.
My problem is that I get an exception on the call to Find() telling me
it needs 2 values, but gets 3. While testing of my code shows that it
only provides 2 values.
Anyone has an idea? If there's an easier way to get what I want that
would be even greater! Thanks in advance.
The exception: Expecting 2 value(s) for the key being indexed, but
received 3 value(s).
My code:
Dim ds As DataSet = products.CreateDataSet(context, 2)
Dim dr As DataRow = ds.Tables(0).Rows.Find(ModelID)
Dim dv As DataView = ds.Tables(0).DefaultView
Dim k() As String = dv.Sort.Split(",")
Dim keys(k.Length) As Object
For i As Integer = 0 To k.Length - 1
Dim s As String = k(i)
s = s.Replace("DESC", "")
s = s.Trim()
If s.Length > 0 Then
keys(i) = dr(s)
End If
Next
Dim index As Integer = dv.Find(keys)