永发信息网

C#如何查找dataset某行数据

答案:1  悬赏:30  手机版
解决时间 2021-04-27 22:23
  • 提问者网友:蓝莓格格巫
  • 2021-04-26 22:59
C#如何查找dataset某行数据
最佳答案
  • 五星知识达人网友:拜訪者
  • 2021-04-26 23:50
private void GetRowsByFilter()
{
DataTable table = DataSet1.Tables["TABLE1"];
string expression;
expression = "Name ='"+sName+"'";
DataRow[] foundRows;

//使用选择方法来找到匹配的所有行。
foundRows = table.Select(expression);

//过滤行,找到所要的行。
for(int i = 0; i < foundRows.Length; i ++)
{
string str1 = Console.WriteLine(foundRows[i]["Name"]).ToString();
string str2 = Console.WriteLine(foundRows[i]["Age"]).ToString();
string str3 = Console.WriteLine(foundRows[i]["Sex"]).ToString();
string str4 = Console.WriteLine(foundRows[i]["ID"]).ToString();
label5.Text = string.Format("Name:({0}) Age:({1})Sex:({2}) ID:({3})", str1, str2, str3,str4);

}
}
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯