ConvertDataTableToString - simple function to debugging.
This extremely simple extension Dataset function I usually use to debugging ASP.NET web sites. Please, see more interesting extension function. How to reorder DataRow with Extension function, Anonymous types, Lambda Expression and Linq Special Row Comparer.
1: Imports Microsoft.VisualBasic
2:
3:
4: Public Module Extension7
5:
6: <Runtime.CompilerServices.Extension()> _
7: Public Function ConvertDataTableToString(Of T As Data.DataTable)(ByVal dt As T) As String
8: Dim Str1 = New StringBuilder()
9: For Each Row As Data.DataRow In dt.Rows
10: For Each Col As Data.DataColumn In dt.Columns
11: Str1.AppendFormat("{0}:{1} ", Col.ColumnName, Row(Col))
12: Next
13: Str1.Append(vbCrLf)
14: Next
15: Return Str1.ToString()
16: End Function
17: End Module
Below you may see a trace result of this simple extension.
Comments (
)
)
Link to this page:
//www.vb-net.com/DataTable-SortRows/ConvertDataTableToString.htm
|
|