Problem comparing two tables in DataSet

Results 1 to 2 of 2

Thread: Problem comparing two tables in DataSet

  1. #1
    Join Date
    Dec 1969

    Default Problem comparing two tables in DataSet

    Hi,<BR><BR>What I need to do is compare two tables that have one column in common - the skillID column. I need to find the SkillID values that are in the first table(JobSkills) but not in the second(ResumeSkills), and then display those values on the screen. I have an existing DataSet called "ds" that contains the two tables I&#039;m comparing. I&#039;m having a lot of trouble figuring out how to compare the values and put the results into a new table so I can bind that to a datagrid. Here&#039;s what I have so far:<BR><BR>&#060;CODE&#062;<BR>Dim NonMatchedSkills As New DataTable() &#039;to hold the values that i&#039;m trying to extract<BR><BR>ds.Tables.Add(NonMatchedSkills)<BR> Dim ctr As Integer<BR>Dim JobSkillID As Integer<BR>Dim ResumeSkillID As Integer<BR>Dim ResumeDataRow As DataRow()<BR><BR>If ds.Tables("JobSkills").Rows.Count &#062; 0 Then<BR> For ctr = 0 To ds.Tables("JobSkills").Rows.Count - 1<BR>&#039;check if the SkillID exists in the ResumeSkills table<BR> JobSkillID = ds.Tables("JobSkills").Rows(ctr)("SkillID")<BR> ResumeDataRow = ds.Tables("ResumeSkills").Select("SkillID=" & JobSkillID)<BR> If RDataRow.Length = 0 Then<BR> ds.Tables("NonMatchedSkills").ImportRow(ds.Tables( "JobSkills").Rows(ctr))<BR> End If<BR> Next<BR>End If <BR>&#060;/CODE&#062;<BR><BR>I can&#039;t even get past adding the new table to the dataset, so I dont&#039; think I&#039;m on the right track here. If anyone can help with this I&#039;d reallty appreciate it. Thanks!

  2. #2
    Join Date
    Dec 1969

    Default RE: Problem comparing two tables in DataSet

    If thats all you need to do then why not do it in the database itself and return only the skill ids that satisfy your criteria.<BR>OR<BR>If you wanna do it in the front end then you might want to use the Dataviews. You might find the RowFilter property of dataview quite handy here<BR><BR>HTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts