Public Sub RemoveAllNullsFromDataTable(ByVal TheDataTable As Data.DataTable)
For Each RowInTable As Data.DataRow In TheDataTable.Rows
For Each ColumnInTable As Data.DataColumn In TheDataTable.Columns
Dim ColumnIndex As Integer = ColumnInTable.Ordinal
If RowInTable.Item(ColumnIndex) Is DBNull.Value Then
Dim ColumnType As Type = ColumnInTable.DataType
RowInTable.Item(ColumnIndex) = Convert.ChangeType(RowInTable.Item(ColumnIndex), ColumnType)
End If
Next ColumnInTable
Next RowInTable
End Sub
Tips and tricks for .NET using ASP and VB code.
Remove all nulls from a data table.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment