Filtering Datasets

  • Thread starter Thread starter JJBean
  • Start date Start date
J

JJBean

Hi,

I am trying to use the select method in Dataset that
filters using a string.

sFindEmp = "LastName = 'Jones'";
dsEmployWC.Tables[0].Select(sFindEmp);

This runs without error but when I assign this

tbEmpNum.Text = dsEmployWC.Tables[0].Rows[0]
["Employee#"].ToString();

its not the correct record. What am I doing wrong?

Thanks,

JJBean
 
JJBean said:
its not the correct record. What am I doing wrong?

Select returns an array of DataRow objects matching your criteria. It does
not filter or otherwise modify the underlying table. Consider using a
DataView instead:

DataView dv = new DataView(dsEmployWC.Tables[0]);
dv.RowFilter = "LastName = 'Jones'";
tbEmpNum.Text = dv[0]["Employee#"].ToString();

Be sure to check that last line. I'm doing this from memory.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
 
Back
Top