Re: Datarow to string by Cor
Cor
Sat Mar 15 01:53:12 CDT 2008
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
<chrisrock2@gmail.com> schreef in bericht
news:6422721d-b9dc-4c59-9f68-a862364aabbf@t54g2000hsg.googlegroups.com...
On Mar 14, 10:07 pm, "John" <J...@nospam.infovis.co.uk> wrote:
> 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...