Navigating a dataset...how?

J

john

Hi,

I'm new to C# and still trying to figure out a few things.

I'm trying to navigate through a dataset and not sure how to go about it
effectively.

I've created a Win form that has a combo box with a list of clients names
that was popluated from a dataset. The dataset was popluated from an Access
database with all information as I don't want to have to go back and forth
to the database all the time.

What I'm trying to do is to then be able to select a clients name in the
combo box and have the information displayed on the form. In VS I've set
databindings between the textboxes and the dataset fields.

I know that I could use the "foreach(DataRow...." command to retrieve the
information but my question is, is there a way to navigate through the
dataset using a filter like "First name = "" and Last Name = "" without
having to iterate through each record in the dataset to find the one I want?


Thanks,

John
 
G

Guest

John,

You can build a dataview off of your dataset to accomplish this. For example:

DataSet ds = new DataSet();
DataView dv = new DataView(ds.Tables[0], "FirstName = 'Fred'", "LastName",
DataViewRowState.CurrentRows);

will build a DataView from the DataSet ds that is filtered by the firstname
Fred and ordered by lastname and where the state is the current rows.

I hope this helps.
-------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top