I am trying to avoid the for loop and use LINQ instead of for loop. Any help will be highly appreciated. I have been trying to use dt.select (a=>...) but it is always throwing error "Cannot convert lambda expression to type string because it is not delegate type".
AutoCompleteStringCollection coll = new AutoCompleteStringCollection();
cn = new SqlConnection("Data Source=.;Initial Catalog=XYX;Integrated
Security=True");
da = new SqlDataAdapter("select UserName from ServiceProviders order
by UserName asc", cn);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
coll.Add(dt.Rows[i]["UserName"].ToString());
}
}