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

RE: datatable.select("Distinct") or such to string? by AdrianMoore

AdrianMoore
Thu Jun 23 16:35:03 CDT 2005

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

---
"DEWright_CA@online.nospam" 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

RE: datatable.select("Distinct") or such to string? by DEWright_CA

DEWright_CA
Thu Jun 23 16:41:02 CDT 2005

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
>
> ---
> "DEWright_CA@online.nospam" 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

Re: datatable.select("Distinct") or such to string? by Adrian

Adrian
Thu Jun 23 20:24:12 CDT 2005

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.

"DEWright_CA@online.nospam"
<DEWright_CA@online.nospam@discussions.microsoft.com> wrote in message
news:7D758E65-E892-4170-889D-B2D77FB8DCB4@microsoft.com...
> 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
>>
>> ---
>> "DEWright_CA@online.nospam" 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



Re: datatable.select("Distinct") or such to string? by v-schang

v-schang
Thu Jun 23 20:59:36 CDT 2005

Hi Dewright,

For datatable retrieveing from physical DATABASE, we'll recommend doing the
filtering in the database's SQL query. For your scenario, since the
DataTable are maually created in memory on the fly, I think we may need to
do the filtering through a loop ourselve since the DataTable's buildin
select method didn't provide Distince function. Here are some articles
which discussing on doing distinct selection on .NET's DataTable manually:

#Select DISTINCT on DataTable
http://weblogs.asp.net/eporter/archive/2005/02/10/370548.aspx

#HOW TO: Implement a DataSet SELECT DISTINCT Helper Class in Visual C# .NET
http://support.microsoft.com/?id=326176


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Re: datatable.select("Distinct") or such to string? by dewright_ca

dewright_ca
Thu Jun 23 21:54:02 CDT 2005

These both look great, will give them a shot in the morning!

Once again I think you have saved my world Steven!
--
D @ premierdata


"Steven Cheng[MSFT]" wrote:

> Hi Dewright,
>
> For datatable retrieveing from physical DATABASE, we'll recommend doing the
> filtering in the database's SQL query. For your scenario, since the
> DataTable are maually created in memory on the fly, I think we may need to
> do the filtering through a loop ourselve since the DataTable's buildin
> select method didn't provide Distince function. Here are some articles
> which discussing on doing distinct selection on .NET's DataTable manually:
>
> #Select DISTINCT on DataTable
> http://weblogs.asp.net/eporter/archive/2005/02/10/370548.aspx
>
> #HOW TO: Implement a DataSet SELECT DISTINCT Helper Class in Visual C# .NET
> http://support.microsoft.com/?id=326176
>
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>

Re: datatable.select("Distinct") or such to string? by v-schang

v-schang
Thu Jun 23 22:13:28 CDT 2005

You're welcome Dewright :-)

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Re: datatable.select("Distinct") or such to string? by Cor

Cor
Fri Jun 24 01:23:23 CDT 2005

Hi,

I have once made a generic routine for this, it is in VBNet however I assume
that you can translate that.

http://groups-beta.google.com/group/microsoft.public.dotnet.languages.vb/msg/f88449bba5e5e1d0

I hope this helps,

Cor



Re: datatable.select("Distinct") or such to string? by dewright_ca

dewright_ca
Fri Jun 24 10:41:07 CDT 2005

Steven,
I went through the MSDN Article and got the code mostly implemented.

dsHelper.SelectDistinct("thinTownships", ds.Tables["AdjacentTownships"],
"TSR");

When I try to assign my datagrid like this,
DataGrid2.SetDataBinding(ds, "thinTownships");

I get a message about WebControl.Datagrid does not contain a definition for
SetDataBinding. So I tried this,

DataGrid2.DataSource = "thinTownships";
DataGrid2.DataBind();

This code returns a table that just has the column header and it actually
put the string thinTownships vertically broken up by charecters.

Any thoughts on how I might be able to do this using a web grid?
--
D @ premierdata


"Steven Cheng[MSFT]" wrote:

> You're welcome Dewright :-)
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>

Re: datatable.select("Distinct") or such to string? by dewright_ca

dewright_ca
Fri Jun 24 10:54:09 CDT 2005

Never you mind, I figured out how to do it, just needed to think my way
through!

Thanks again works like a charm!
--
D @ premierdata


"DEWright_CA@online.nospam" wrote:

> Steven,
> I went through the MSDN Article and got the code mostly implemented.
>
> dsHelper.SelectDistinct("thinTownships", ds.Tables["AdjacentTownships"],
> "TSR");
>
> When I try to assign my datagrid like this,
> DataGrid2.SetDataBinding(ds, "thinTownships");
>
> I get a message about WebControl.Datagrid does not contain a definition for
> SetDataBinding. So I tried this,
>
> DataGrid2.DataSource = "thinTownships";
> DataGrid2.DataBind();
>
> This code returns a table that just has the column header and it actually
> put the string thinTownships vertically broken up by charecters.
>
> Any thoughts on how I might be able to do this using a web grid?
> --
> D @ premierdata
>
>
> "Steven Cheng[MSFT]" wrote:
>
> > You're welcome Dewright :-)
> >
> > Steven Cheng
> > Microsoft Online Support
> >
> > Get Secure! www.microsoft.com/security
> > (This posting is provided "AS IS", with no warranties, and confers no
> > rights.)
> >
> >