DataView

  • Thread starter Thread starter web1110
  • Start date Start date
W

web1110

This is a rehash of a response question I made down below.

I am playing with the NorthWind database. I have created a DataSet and
loaded the Employees table into it. I have created a DataView on that
table.

Now, I am having trouble putting all the parts together to retrieve a single
row of that DataView. For instance, if I want to retrieve the row where
EmployeeId='2' and display the FirstName of that employee, what steps do I
need to perform? What I've tried keeps getting syntax errors or exceptions.

For instance, both

dataView1.RowFilter="EmployeeId != '2'";
dataView1.RowFilter="EmployeeId != 2"; // No single quotes

Gives me the error:

Cannot interpret token '!' at position 12.

Since the filter removes the rows that match the contition, I have to
negate the condition to get the data I want.

I'd appreciate some help.

Thanx,
Bill
 
Thanks again. Mind is on other things I guess. Anyway, additional details
on the steps would be very helpful.
 
As I play with this, I find that a table automatically has a defaultview
that can be used. Therefore, using a DataView does not appear to be
necessary. I think I am I making progress here.
 
Bill,

You mean
dataView1.RowFilter = "EmployeeId='2'"
string MyFirstName = dataView1.Item[0]["FirstName"];


Cor
 
That's it. It was too simple to figure out except Item wasn't recognzed.
Had to use:

string MyFirstName=dataView1[0]["FirstName"].ToString();

Thank you much,
Bill
 
Back
Top