What dr gets here.
DataRow[] dr = objds.Tables[0].Select("ProcessName = '" + tnProcName.Text + "'");
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.
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 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
Here the MSDN docs
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("'", "''") + "'");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With