A more concise method would be to use a DataView. A DataView is a subset of the data, and is basically defined by passing a filter, sort order and or rowstate. In the case of your data, a simple filter should result in just one row retunred.
As an example, use the following after your " SQLAdapter.Fill(dt)" line:
Dim value3 As Integer 'Something to hold the value in
Dim dv As New DataView(dt)
dv.RowFilter = "value1 <= x and value2 >= x"
If dv.Count = 0 Then 'Not found
'do something if not found
MessageBox.Show("Not found in range...")
Else
value3 = CType(dv.Item(0)("value3")
'Do something with value3...
End If
Main Topics
Browse All Topics





by: iboutchkinePosted on 2005-01-08 at 13:51:21ID: 12994243
YOu can perform search on datatatble. The only condition - the dat must have key
Dim dr As DataRow = dt.Rows.Find(Value of the key)' ID of ths range
'get the value value in one of the fields
msgbox(dr.Item("Value3")
let me know if need to know how to set the key