CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Friday, September 15, 2006

.NET DataRow to string function

Shared Function RowToString(ByVal SourceRow As DataRow) As String
Dim SB As New Text.StringBuilder
If Not SourceRow Is Nothing Then
Dim SR As DataRow = SourceRow
Dim ST As DataTable = SR.Table
Dim SC As DataColumn
For Each SC In ST.Columns
Try
SB.Append(SC.ColumnName & " = " &
SR.Item(SC.ColumnName) & " " &
System.Environment.NewLine)
Catch oEx As Exception
End Try
Next
Else
SB.Append("SourceRow not available, stacktrace = " & System.Environment.StackTrace)
End If
Return SB.ToString.TrimEnd
End Function

Post a Comment

Anonymous said...

Excellent! Thanks. really work!!!