Hi
I have a DataTable and get selected values out of it in a DataRow collection. I have the code that I want to make it run. Not sure if this is the correct approach to store column names and value in memory for later use?
The statement in BOLD is giving error. How to access DataColumn from DataRow[] array?
I have a DataTable and get selected values out of it in a DataRow collection. I have the code that I want to make it run. Not sure if this is the correct approach to store column names and value in memory for later use?
Code:
DataTable dt = ds.Tables["Employee"];
DataRow[] foundEmpRows = dt.Select("Dept = 10");
NameValueCollection nvEmp = new NameValueCollection();
foreach (DataRow dr in foundEmpRows)
{
[B]foreach (DataColumn dc in foundEmpRows)[/B]
{
nvEmp.Add(dc.ColumnName, dr[dc]);
}
}
Comment