DataView.Find (SQL Server 2000)

B

bgsd

I need to be able to sort/search a datatable for 2
columns, both of type integer. Is this possible?

Dim dv As New DataView(MyDataTable,...)
Dim dr As DataRowView
Dim iIndex As Integer
Dim objSearch(1) As Object

dv.Sort = ("Column1, Column2 ASC")
objSearch(0) = 5 'Locate 5 in column 1
objSearch(1) = 6 'Locate 6 in column 2

iIndex = dv.Find(objSearch)

Will this find rows in my view where Column1 = 5 AND
Column2 = 6? Or will it find rows where Column1 = 5 or
6 AND rows where Column2 = 5 or 6?

As an alternative, I could apply a filter upon the
DataView when enstantiating it. However, wouldn't this
be less efficient/concise than DataView.Find?

-bgsd
 
M

Miha Markic

bgsd said:
I need to be able to sort/search a datatable for 2
columns, both of type integer. Is this possible?

Dim dv As New DataView(MyDataTable,...)
Dim dr As DataRowView
Dim iIndex As Integer
Dim objSearch(1) As Object

dv.Sort = ("Column1, Column2 ASC")
objSearch(0) = 5 'Locate 5 in column 1
objSearch(1) = 6 'Locate 6 in column 2

iIndex = dv.Find(objSearch)

Will this find rows in my view where Column1 = 5 AND
Column2 = 6?

Yes, the first object is for first column (in Sort property - thus Column1)
as the second is per second (thus Column2).

Or will it find rows where Column1 = 5 or
6 AND rows where Column2 = 5 or 6?

No.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top