Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare Two DataSets

Status
Not open for further replies.

Elegabalus

Programmer
Jan 13, 2005
71
CA
I've got dataset that gets a list of employees from my database (dsFullList).

I've got a second dataset that gets a list of employees that meet certain criteria (dsCriteriaList).

How can I compare these two datasets? I want to have some logic that basically states: foreach record in dsCriteriaList that matches a record in dsFullList, then...

For instance, for the dsFullList:

Code:
EmployeeID
----------
1
2
3
4
5
6
7
8
9

For the dsCriteriaList:
Code:
EmployeeID
----------
1
2
3

Any help is appreciated.
 
You will have to loop through each dataset and compare the EmployeeID, then do something if they match.
Code:
dim i, ii, EmpId as integer
For 1 = 0 to dsFullList.Tables(0).Rows.Count - 1
    EmpID = dsFullList.Tables(0).Rows(i).Item("EmployeeID")

   For ii = 0 to dsCriteriaList.Tables(0).Rows.Count - 1
      IF EmpID = dsCriteriaList.Tables(0).Rows(i).Item("EmployeeID") Then
         ...Do Somehting
      End IF
    Next
Next
Jim
 
You could also do something similar by using DataView's and their RowFilter method.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top