Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for DBNull in DataTable
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00887448
Message ID:
00887744
Views:
9
Bonnie, you will love this as an answer

How about:-

row.IsNull((col))

or put in context

Dim row As DataRow
For Each row In dt.Rows
For Each col In dt.Columns
If row.IsNull((col)) Then
Console.WriteLine(col.ColumnName & " - " & col.DataType.ToString & " : null")
Else
Console.WriteLine(col.ColumnName & " - " & col.DataType.ToString & " : " & _
CType(row(col), String))
End If
Next
Next

but it still doesn't answer the question about byte,
hence my actual code looks like this


'test code
Dim col As DataColumn
For Each col In dtTscope.Columns
Console.WriteLine(vbTab & col.ColumnName & " - " & col.DataType.ToString)
Next col


Dim row As DataRow
For Each row In dtTscope.Rows
For Each col In dtTscope.Columns
Try
If row.IsNull((col)) Then
Console.WriteLine(col.ColumnName & " - " & col.DataType.ToString & " : null")
Else
Console.WriteLine(col.ColumnName & " - " & col.DataType.ToString & " : " & _
CType(row(col), String))
End If
Catch ex As Exception
MsgBox(ex.ToString & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & col.DataType.ToString)

End Try
Next
Next


PS How do you mark code as not formatted, explain to some one who has never seen html, its not my thing (yet??)
John T Barton
A single picture (or bit of code) is worth a thousand words
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform