I have a dataview, and I am trying to "clone" its structure only in part, by creating a new table via code. I cut out most of the columns, so this is easier to read. My question is - Why does this always seem to add things a a string?
Later in my code, I try to sort based on "View_Order", but it acts like a string. The values sort as 1,2,20,21,22,3,4, NOT 1,2,3,4,20,21,22 like it should.
Using Cint() while moving the values from table to table didn't work for me... and the boolean becomes text as well. Is the problem in this code, or would it be elsewhere?
-
Private Function ConvertTable(ByVal ds As DataSet, ByVal TableName As String, Byval WHEREexpression As String, Byval SORTexpression As String) As DataTable
-
'For Schedule Tasks, convert all "dates+times" to "dates only" as strings
-
-
Dim dv As DataView = GetViewTable(ds.Tables(TableName), WHEREexppression, SORTexpression)
-
Dim dt As New DataTable
-
-
dt.Columns.Add(New DataColumn("Task", GetType(String)))
-
dt.Columns.Add(New DataColumn("View_Order", System.Type.GetType("System.Int64")))
-
dt.Columns.Add(New DataColumn("Completed", GetType(Boolean)))
-
-
For i = 0 To dv.Table.Rows.Count - 1
-
dt.Rows.Add()
-
-
dt.Rows(i).Item("Task") = dv.Table.Rows(i).Item("Task").ToString
-
-
dt.Rows(i).Item("View_Order") = CInt(dv.Table.Rows(i).Item("View_Order").ToString)
-
Try
-
dt.Rows(i).Item("Completed") = dv.Table.Rows(i).Item("Completed")
-
Catch ex As Exception
-
End Try
-
Next i
-
-
Return dt
-
End Function
-