I would want to make the search faster as it takes a long time to retentive the data that i require.. is the a faster method to so this..I have written the code below to to allow me to search through a data table and retrieve data which currently is fully functional. its the nested for loops which i am using and wondering if there is another method of completing the tasks that the foor loops get
DataTable sqlData = GetConfiguration();
// var q = sqlData.AsEnumerable().Where(data=> data.Field<String>("slideNo")=="5");
var w = sqlData.AsEnumerable().Where(data => data.Field<String>("slideNo") == "5")
.Select(data => data.Field<String>("QuestionStartText")).Distinct();
List<String> queryResult = new List<String>();
foreach (var item in w.ToArray<string>())
{
if (item != null)
{
String queryString = item;
//queryResult.Clear();
for (int i = 0; i < excelDataTable.Columns.Count; i++)
{
for (int k = 2; k < excelDataTable.Rows.Count; k++)
{
String row = "";
bool check = excelDataTable.Rows[k][0].ToString().StartsWith(queryString);
if (check)
{
for (int j = 0; j < excelDataTable.Columns.Count; j++)
{
string value = excelDataTable.Rows[k][j].ToString()+":";
row += value;
}
if (!queryResult.Contains(row))
{
queryResult.Add(row);
}
}
}
}
}
}
row? – ANeves Nov 26 '12 at 16:51wand how many cells inexcelDataTable? – tia Apr 26 at 6:00