chris,
I would not use the name dataRowBuilder in this case, I had to look twice
before I saw what you was doing. That is not only for me, but probably for
everybody even you who has to maintain it after some months.
Cor
<
[email protected]> schreef in bericht
Hi
How can I save all values in a system.data.datarow to a string? I need
this
for error logging purposes.
Thanks
Regards
I'm assuming you have access to the datacolumns that are part of that
datarow correct?
Private Function ConvertDataRowToString(ByVal dr As DataRow, ByVal
columns As System.Data.DataColumnCollection) As String
Dim dataRowBuilder As New System.Text.StringBuilder(100)
For Each dc As DataColumn In columns
dataRowBuilder.AppendFormat("{0} = {1}", dc.ColumnName,
dr(dc.Ordinal))
dataRowBuilder.AppendLine()
Next
Return dataRowBuilder.ToString
End Function
Dim rowData As String = ConvertDataRowToString(yourDataRowGoesHere,
yourDataTable.Columns)
Let me know if you don't understand...