Opinion on how to handle a DataSet
-
I have a
DataSet
which contains three rows with 4 columns in each row. I want to print out the contents of theDataSet
so I have written this:foreach (DataRow row in MyDataSet.Tables[0].Rows)
for (int i = 0; i < MyDataSet.Tables[0].Columns.Count; i++)
Console.WriteLine("Value {0}", row.ItemArray[i]);Is there a better way than having a for statement and looking at the ItemArray? I tried the following but I only get the column names:
foreach (DataRow row in MyDataSet.Tables[0].Rows)
foreach (DataColumn column in dsUpdates.Tables[0].Columns)
Console.Write(column.ToString());If I am missing the basics can someone tell me where or what to read to understand handling DataSets? :)
-
I have a
DataSet
which contains three rows with 4 columns in each row. I want to print out the contents of theDataSet
so I have written this:foreach (DataRow row in MyDataSet.Tables[0].Rows)
for (int i = 0; i < MyDataSet.Tables[0].Columns.Count; i++)
Console.WriteLine("Value {0}", row.ItemArray[i]);Is there a better way than having a for statement and looking at the ItemArray? I tried the following but I only get the column names:
foreach (DataRow row in MyDataSet.Tables[0].Rows)
foreach (DataColumn column in dsUpdates.Tables[0].Columns)
Console.Write(column.ToString());If I am missing the basics can someone tell me where or what to read to understand handling DataSets? :)