Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C# (http://www.programmingforums.org/forum16.html)
-   -   datatable (http://www.programmingforums.org/showthread.php?t=13740)

programmingnoob Aug 10th, 2007 4:16 AM

datatable
 
so I have created a datatable in C#...
and i have used dataview.findrows() method to find rows that have say column3 entry equal to "s"...
now I have all the rows that fit that criteria...
now among those rows, i want to compare column4, column5, column6, column8 of these rows with an array of 4 words to see if any of those columns equal any of those words in the array....
now how do I do it?
I mean do I do it all manually? or are there any sophisticated ways to do it?

Ghost Aug 10th, 2007 6:48 AM

Maybe it is because it is 3am when I'm reading this, but could you try to make your question a little clearer?

programmingnoob Aug 10th, 2007 1:56 PM

Quote:

Originally Posted by Ghost (Post 131962)
Maybe it is because it is 3am when I'm reading this, but could you try to make your question a little clearer?

or maybe it's because I wrote that question at 3 AM myself
lol but let me try again...

I have a datatable in C#....
you know findrows method? it returned me multiple rows which fit a criteria (say the criteria was column3 = "sk") ...
now I have all the rows from the datatable that have column3 = "sk". Now I dont have a problem doing this so far. The problem arrives at next step....

now i have 4 strings (maybe stored in an array)... now I want to see whether any of these 4 strings match any of the strings stored in column4, column5, column6, column7 of the rows found using findrows method

does the question make more sense now?

Arla Aug 10th, 2007 3:30 PM

Could you recurse the rows you found looking in each row for the string(s)?

programmingnoob Aug 10th, 2007 3:57 PM

Quote:

Originally Posted by Arla (Post 131975)
Could you recurse the rows you found looking in each row for the string(s)?

could you elaborate please?

Arla Aug 13th, 2007 2:27 PM

Okay, all in theory (not bothered to check this exactly) but...

findrows() returns a DataRowView (from what I can tell) so from that you could use something like (grammer is almost certainly wrong, because I'm putting it in pseudo code, not real C# code)

:

foreach Row in DataRowView
{
  if Row["column1"] = WordArray[0]
  {
      do something
  }
  if Row["column2"] = WordArray[1]
  {
    do something else
  }
  ...
}



All times are GMT -5. The time now is 2:59 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC