|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Selecting specific columns from a dataview?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. 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 I have a complete table within a dataset.news:1113597754.030984.100180@o13g2000cwo.googlegroups.com... Hello, 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. 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
Determine if "Hide extensions for known file types" is active
An absence of IntelliSense in this situation What scope is best for defining Enum type? VB6 to VB.Net Conversion How to overload method of third party component? creating an array as property of a class Limiting the directories somebody can browse to..... Creating a custom log Passing parameters to Data Adapter Hierarchal recordset |
|||||||||||||||||||||||