Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Checking for DBNull in DataTable
Message
From
18/03/2004 19:51:02
 
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00887448
Message ID:
00887747
Views:
10
Cool, John ... glad you figured it out. I've never used the row.IsNull() because just checking a column against DBNull.Value works fine with C# and it's basically the same thing. But you know, it does *look* a little cleaner, so maybe I'll give it a try.

Try putting these tags (without the spaces) < pre > around whatever you need formatted < /pre >.

~~Bonnie


>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??)
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform