Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Checking for DBNull in DataTable
Message
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Divers
Thread ID:
00887448
Message ID:
00887744
Vues:
10
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform