lost/confused with DataView's

  • Thread starter Thread starter Kyle Klaus
  • Start date Start date
K

Kyle Klaus

Alright, I'm going to attribute this problem to my lack of knowledge on the
subject, and that I can't find any good resources describing it.

What I have is an application that is used to view the contents of a single
table/query, who's contents I want filtered to show only the values with a
certian string in a given column. The table/query can be very large, and it
may take a bit to read and get to the user, so I don't want to re-read the
entire database everytime I change what my filter value is.

I thought the fastest/easiest way to do this would be to grab all the data
right off the bat, put it in a dataset, and then use dataview's to filter
what I wanted to see and display that. but I can't figure out the dataview.
I can populate the dataset and then create the dataview, and properties like
this:

Dim tmp_dataview As DataView = New DataView(priv_dataset.Tables(0))
tmp_dataview.RowFilter = "Project='" & Me.ComboBox1.SelectedItem & "'"

But once I get here... I am not sure what I can do with the dataview, or how
to access it. Idealy I would like to get to the collection of rows that fit
the RowFilter criteria.

Any help is greatly appreciated.

..: Kyle

P.S. Would a Stored Procedure work better for this?
 
If you are binding to a datagrid, or some other control, just use the
dataview as the datasource.
 
I'm not binding though, because I'm taking the data and formatting it a bit,
and some fields get ignored etc... I have an extended listview that steps
though the rowitems in a rowitemcollection and does its magic with each one.

I don't know much about binding (yet) but maybe I should look into it? What
my function does now is creates ListView Items (and subitems) of all the
columns in a table, except two ('Tag' and 'ImageIndex' Columns) which are
used to assign the tag, and imageindex properties of the ListViewItem... can
databinding do this?
 
But once I get here... I am not sure what I can do with the dataview, or how
to access it.

You can enumerate through it, like through a DataTable, too

foreach(DataRowView oDRV in DataView)
{
// do stuff with your data view's row
}

You'll only get the rows that match your filter criteria (as
expected), and possibly sorted according to your sort criteria.

P.S. Would a Stored Procedure work better for this?

If you can do stored procs, they're almost always better, since
they're precompiled and ready to execute, on the DB server, and don't
have to be parsed, prepared and compiled before each execution.

Marc

================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
 
Back
Top