Private Function CreateTable() As DataTable
Dim drData As SqlDataReader
Dim flgNextResult As Boolean = True
‘create a new empty Table object
Dim objTable As New DataTable(”MyTable”)
‘Add fields to the table
objTable.Columns.Add(”Number”, System.Type.GetType(”System.String”))
objTable.Columns.Add(”Description”, System.Type.GetType(”System.String”))
objTable.Columns.Add(”Amount”, System.Type.GetType(”System.Decimal”))
Dim objDataRow As DataRow
Dim decAmount As Decimal
Dim strAccount As String
Dim strDesc As String
‘Get the results from the Function above
drData = GetSPResults()
‘Loop through each resultsets
Do Until Not flgNextResult
‘Loop through each row of a resultset
Do While drData.Read()
If Not drData.IsDBNull(0) Then
decAmount = drData(”Amount”)
strAccount = drData(”Number”)
strDesc = drData(”Description”)
‘Generate new row in table
objDataRow = objTable.NewRow()
‘Add values to fields in the row
objDataRow(”Number”) = strAccount
objDataRow(”AmountPY”) = decAmountPY
objDataRow(”Description”) = strDesc
‘Add the row to the table
objTable.Rows.Add(objDataRow)
End If
Loop
flgNextResult = drData.NextResult()
Loop
drData.Close()
‘Return table object Isoftwarehouse.net
Return objTable
End Function