Home All Groups Group Topic Archive Search About

Selecting specific columns from a dataview?

Author
15 Apr 2005 8:42 PM
Tmuld
Hello,

I have a complete table within a dataset.

I want a dataview to show particular filtered data - works great with
the dv.rowfilter.

But can I display only certain columns that are filtered?

Right now in my rowfilter I have something like this:

dv.RowFilter = "Title like '%Whales%' OR Genus like 'Megaptera'"

This prints all of the fields in the table (30).  I want to show only 4
fields

I cannot get a away with:

dv.rowfilter = "select Title, Genus, [Climate ID], Endangered from
Animals where Title like '%Whales%' OR Genus like 'Megaptera'"

I get this error: Missing operand after 'Title' operator

*Note "Climate ID" is the name of a column (yes it has a space in it so
I bracketed it).

So in row filter you cannot put in a full sql statement....

The dataset cannot be changed.

Anyway to pull specific columns from this table?

Thanks,

Tmuld.

Author
16 Apr 2005 3:35 AM
Ken Tucker [MVP]
Hi,

        Add a tablestyle to your datagrid.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/wnf_custdatagrid.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchformattingwindowsformsdatagridvisualbasicprimer.asp

Ken
--------------------
"Tmuld" <tmuld***@spliced.com> wrote in message
news:1113597754.030984.100180@o13g2000cwo.googlegroups.com...
Hello,

I have a complete table within a dataset.

I want a dataview to show particular filtered data - works great with
the dv.rowfilter.

But can I display only certain columns that are filtered?

Right now in my rowfilter I have something like this:

dv.RowFilter = "Title like '%Whales%' OR Genus like 'Megaptera'"

This prints all of the fields in the table (30).  I want to show only 4
fields

I cannot get a away with:

dv.rowfilter = "select Title, Genus, [Climate ID], Endangered from
Animals where Title like '%Whales%' OR Genus like 'Megaptera'"

I get this error: Missing operand after 'Title' operator

*Note "Climate ID" is the name of a column (yes it has a space in it so
I bracketed it).

So in row filter you cannot put in a full sql statement....

The dataset cannot be changed.

Anyway to pull specific columns from this table?

Thanks,

Tmuld.
Author
16 Apr 2005 7:50 AM
Cor Ligthert
Tmuld,

No you cannot create a dataview with less columns than its underlying
datatable.

A dataview is only a view on a dataset. Nothing more.  It has a rowfilter
however not a columnfilter.

So you have to do it in your controls. What can with the standard controls
only be a problem for the datagrid. When it is a winform, look than at the
links Ken has provided, because to do it is a part of the datagrid..

I hope this helps,

Cor