You could simply use String.Join
and pass row.ItemArray
:
For Each row As DataRow In sqlDataset.Tables(0).Rows
Response.Write(String.Join("", row.ItemArray))
Next
That works since DBNull.ToString
returns an empty string.
If you want to address every column, you can use the strongly typed DataRowExtensions.Field
method which supports nullables and return null
/Nothing
for string. Then you could use the null-coalescing operator
(??
in C#, If
in VB).
Dim rowInfo = String.Format("{0}{1}{2}",
If(row.Field(Of String)("Column1"), ""),
If(row.Field(Of String)("Column2"), ""),
If(row.Field(Of String)("Column3"), ""))
However, note that String.Format
will convert null
/Nothing
to ""
implicitely anyway, so the If
is redundant and just fyi.
MSDN:
If the object specified by index is a null reference (Nothing in Visual Basic), then the format item is replaced by the empty string ("").