ds.Tables [0] .Select()代表什么 [英] What does ds.Tables[0].Select() represents
问题描述
博士到这里来.
DataRow[] dr = objds.Tables[0].Select("ProcessName = '" + tnProcName.Text + "'");
我正在获取dr {System.Data.DataRow [4]},而不是一行.
I am getting dr{System.Data.DataRow[4]} and not the line individually.
博士现在由行列表组成.我该如何比较数据行中存在的列.
In dr now consists of list of rows.How can i compare the column present in data row.
推荐答案
它返回一个DataRow数组,该数组与Select方法的第一个参数表示的选择条件匹配
It returns an array of DataRow that match the selection criteria expressed by the first parameter of the Select method
DataRow[] dr = objds.Tables[0].Select("ProcessName = '" + tnProcName.Text + "'");
foreach(DataRow r in dr)
{
string procName = r["ProcessName"].ToString();
treeView1.Nodes.Add(procName);
}
Select具有四个重载以微调结果
Select has four overloads to fine tune the results
DataTable.Select(); // return all (same as dataTable.Rows)
DataTable.Select(filter); //The above one
DataTable.Select(filter, sort) //Filtered and/or sorted
DataTable.Select(filter, sort, rowstate) // Filtered and/or sorted and/or in a particular state
可能不是您的情况,但是请记住,如果expression参数具有单引号,那么您需要将其加倍以避免在计算表达式时出现语法错误
Probably it is not your case, but keep in mind that if the expression parameter has a single quote then you need to double it to avoid a syntax error when the expression is evaluated
DataRow[] dr = objds.Tables[0].Select("ProcessName = '" +
tnProcName.Text.Replace("'", "''") + "'");
这篇关于ds.Tables [0] .Select()代表什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!