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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

datatable.select, specified columns, distinct rows

Status
Not open for further replies.

mgriffith

MIS
Jul 3, 2001
177
US
i have a datatable that i need to pass to severeral functions (by reference), each containing a nested loop....

the first function needs to select the "department" column, and only distinct rows (the tricky part i think..this is what i really need help with).

the second function needs to select the "operations" column where "department=@department" (parameter passed into function), and only distinct rows

nested more, etc.

i'd really rather not keep running back to the database and running select commands, so i'm asking if anyone knows how to do this. i've figured parts of it out but i can't seem to tie them all together

i have a big table, dt, full of columns and rows...i can do
dt.Columns["deptartment"] to get a DataRow[] with only the column i need....should i then make a function that loops through each record in the DataRow[] and only adds it to a new DataRow[] (which will be returned) if a search through the new DataRow[] finds nothing for the current item in the original DataRow[]?
then when i need to do filtering, like dt.Select("department='"+dept+"'"), i get a new DataRow[] with more columns than i need (i don't need to use all of them)....is there a way to select multiple columns, but not all, or is it alright (in the name of speed) to return the entire row and access the columns in it though the DataColumn[]?

this all seems like a big speed issue....is there something built into the DataTable (or DataView, or parent DataSet) that would let me do this without all of my own searching?

any suggestions? comments? i'm open for critisicm/rethinking because it's early in the application.

thanks.
[afro] mike griffith
----------------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top