How to filter the data in Dataset ?

Posted by Johnseelan under Regular Expressions on 1/24/2011 | Points: 10 | Views : 16990 | Status : [Member] | Replies : 3
How to filter the data in Dataset ?
can any one give me the example code?




Responses

Posted by: T.saravanan on: 1/24/2011 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi,

Refer the following Code.....
Here
ds --> Your Output DataSet.

// Condition in DataSet
string sCond = string.Format("sName = 'AK Man'");
DataRow[ ] drArray = ds.Tables[0].Select(sCond);
DataTable dtData = new DataTable();
dtData = ds.Tables[0].Clone();
foreach(DataRow dr in drArray)
{
dtData.ImportRow(dr);
}


Try this Code...
Cheers :)


Thanks,
T.Saravanan

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/24/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
HI,

Syntax for filtering would be like this

DataSet.Tables[0].Select("UserName like 'Kar%'");


Thanks
Karthik
www.f5Debug.net

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 1/24/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi
i think you use RowFilter Property to Filter Dataset
ds.RowFilter = "City = 'Berlin'"


Thanks * Regards's
Prabhakar





Best Regard's
Prabhakar

Johnseelan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response