Tuesday, May 20, 2014

Filering values in a Dataset

Hi all,
 Today I'm going to tell you about filtering values from a Dataset where the data get from SQl and stored in a dataset.
 Later on you need to filter the values for a given criteria from the dataset you have.
 you can do that by:

 DataSet DSpocode=new DataSet();
 DSpocode="Dataset select from SQL"
 DataTable table = DSpocode.Tables[0];
 for (int i = 0; i < DSpocode.Tables[0].Rows.Count; i++)
 {
 string expression = " substr('PD_CODE',3) like'%" + 65600+ "%'";
 DataRow[] foundRows = table.Select(expression);
 int rowCount = foundRows.Length;
}
 // PD_CODE is the coliumn name in the dataset.
 //I got the count where PD code like 65600. Likewise you can alter this to fulfill your requirement.

Thanks.

No comments: