How do you loop through a strongly typed DataSet?
We have the following defined in the DataSet designer:
DataSet name: DataSetSchedules
DataTable name: DataTableSchedules
TableAdapter name: DataTableDataAdapterSchedules
This is a code sample I found using Google:
Dim col As DataColumn
Dim dt as DataTable
Dim dr as DataRow
Dim strMyValue AS String = ""
dt = ds.Tables(0)
For Each dr In dt.Rows
For Each col In dt.Columns
StrMyValue = dr(col.ColumnName)
Next
Next
Since a DataSet was already created in the DataSet desiner, I tried this:
Dim col As DataColumn
Dim dt as DataTable
Dim dr as DataRow
Dim strMyValue AS String = ""
dt = DataSetSchedules.Tables(0)
Intellisence told me that "Tables" was not a choice so I'm stuck.
Most of the code samples I found show that this is how to do it, but I don't think that this applies to strongly typed DataSets.
Can you show the correct coding needed to loop through DataSetSchedules and get the value in dr(col.ColumnName)?
Best Answer
Try This :
or as @Tim Suggested use the strongly typed Tables. see MSDN