<\/script>')

What does ds.Tables [0] .Select () do

What is the doctor doing here.

DataRow[] dr = objds.Tables[0].Select("ProcessName = '" + tnProcName.Text + "'");

I get dr {System.Data.DataRow [4]}, and not a line separately.

The dr now consists of a list of strings. How can I compare the column present in the data row.

+3
source share
2 answers

It returns an array of DataRow that matches 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);

}

The choice has four overloads for fine-tuning 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 are the MSDN docs

This may not be your case, but keep in mind that if the expression parameter has a single quote, you need to double it to avoid a syntax error when evaluating the expression

DataRow[] dr = objds.Tables[0].Select("ProcessName = '" + 
               tnProcName.Text.Replace("'", "''") + "'");
+2
source

.Select Datarows "ProcessName = '" + tnProcName.Text + "'"

0

All Articles