Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Loop or iterate through resultset or recordset by column, using C# only Expand / Collapse
Posted Monday, October 21, 2013 5:32 PM


Group: General Forum Members
Last Login: Thursday, May 15, 2014 8:51 PM
Points: 183, Visits: 480
I have a result set like (in SSIS actually) -

ID, Name, Address
1,John, Japan
2,Sarah, UK
3,Jeremy, USA

I want to be able to select any column out of the above in the result set/record set and then iterate over that column's rows. How do I do that ?
Post #1506927
Posted Tuesday, October 22, 2013 2:19 AM



Group: General Forum Members
Last Login: Yesterday @ 6:23 AM
Points: 15,499, Visits: 13,162
string columnname = "Name";
DataTable myTable; -- don't forget to initialize datatable

foreach(Datarow row in myTable.Rows){

Haven't tested it, but it shouldn't be far off.

How to post forum questions.
Need an answer? No, you need a question.
What’s the deal with Excel & SSIS?

Member of LinkedIn. My blog at SQLKover.

MCSA SQL Server 2012 - MCSE Business Intelligence
Post #1507011
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse