-
Datarow
I got this code off of another site (it was in c# orginally) and I moved it to vb.net. But it does not like the line:
r(0) = dt.Columns(k).ToString()
I get the error: Value of type 'String' cannot be converted to 'System.Data.DataRow'.
Code:
Function FlipDataSet(ByVal my_DataSet As DataSet) As DataSet
Dim ds As New DataSet()
Dim dt As New DataTable()
Dim k, j, i As Integer
For Each dt In my_DataSet.Tables
Dim table As New DataTable()
For i = 0 To dt.Rows.Count
table.Columns.Add(Convert.ToString(i))
For k = 0 To dt.Columns.Count
Dim r As DataRow()
r(0) = dt.Columns(k).ToString()
For j = 1 To dt.Rows.Count
r(j) = dt.Rows(j - 1)(k)
Next
table.Rows.Add(r)
Next
ds.Tables.Add(table)
Next
FlipDataSet = ds
Next
End Function
Any thoughts?
-