Just to clarify my understanding. You have a DataTable called
AdjacentTownships that contains a column TSR and rows which contain
duplicate data in the TSR column. You want to retrieve a distinct set of
values for the TSR column and process each row in a for loop.
Make sure the DataTable belongs to a DataSet, then using the QueryADataSet
assembly,
DataView dv = QueryADataSet.DsCommand.Execute("SELECT DISTINCT TSR FROM
AdjacentTownships" , ds);
for (int i = 0; i < dv.Count; i++)
{
DataRow dr = dv[i].Row;
// parse/process data in row
}
If you want distcint rows, then the query becomes SELECT DISTINCT * FROM
AdjacentTownships
Hope this helps
Ad.
"(E-Mail Removed)"
<(E-Mail Removed)@discussions.microsoft.com> wrote in message
news:7D758E65-E892-4170-889D-(E-Mail Removed)...
> Ok, that looks interesting, but how can I use it against a table I have
> created in memory. Then put the data that is returned into a format that I
> can feed into my for loop?
>
> "Adrian Moore" wrote:
>
>> You might be interested in the assembly I've been working on at
>> http://www.queryadataset.com. Besides DISTINCT, it lets you perform
>> complex
>> SQL SELECT statements including UNION, JOINS, GROUP BY, HAVING, ORDER BY,
>> sub-queries, etc against the tables in a dataset.
>>
>> The web-site allows you to upload your own XML data fragment, DataSet or
>> resultset and issue queries using the QueryADataSet assembly.
>>
>> Adrian Moore
>> http://www.queryadataset.com
>>
>> ---
>> "(E-Mail Removed)" wrote:
>>
>> > I am hitting a bit of a wall - I am building a table -
>> >
>> > public DataTable theTownships = new DataTable("AdjacentTownships");
>> > public DataTable buildTownshipTable()
>> > {
>> > DataColumn tscolumn; //Townships-Range Field
>> > tscolumn = new DataColumn();
>> > tscolumn.DataType = System.Type.GetType("System.String");
>> > tscolumn.ColumnName = "TSR";
>> > tscolumn.ReadOnly = false;
>> > tscolumn.Unique = false;
>> > theTownships.Columns.Add(tscolumn);
>> >
>> > return theTownships;
>> > }
>> >
>> > This table is built from another query where each coloumn in that row
>> > is
>> > turned into a row here. So I can have between 1 and 0 rows, some can be
>> > duplicates.
>> >
>> > What I need to do is then select the distinct rows from this table and
>> > pass
>> > them to a for loop that I can then parse/process each of the distinct
>> > rows.
>> >
>> > Any and all suggestions would be greatly appreciated!!
>> > --
>> > D @ premierdata