I don't think that does what you want, or expect.
That code runs through the Columns of a DataTable - so the objects it adds to your List are DataColumns, which aren;t a lot of use on their own, because they do not contain values read from the database, but descriptions of what type of values the column contains.
Probably what you want are the Rows instead, or more likely the values from the rows.
Try this:
DataTable dt = ds.Tables[0];
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn col in dt.Columns)
{
Console.Write("{0} ", row[col]);
}
Console.WriteLine();
}
And you should see what I mean.
BTW: it is a poor idea to create a
List<object>
at all - the whole idea of using a
List<T>
instead of the outdated
ArrayList
is that it is strongly typed - it will not accept "any old value" but expects only the specific type you create it for. This means that many faults can be found at compile time, instead of waiting until the user finds them at run time!