Module RecordSetToDataSet
Public Function collectionChange(ByVal _ODyn As OracleInProcServer.OraDynaset) As DataSet
Dim countR As Integer
Dim countC As Integer
Dim i As Integer
Dim j As Integer
Dim aoDataSet As DataSet
aoDataSet = New DataSet
Dim aoTable As DataTable
aoTable = New DataTable
countR = _ODyn.RecordCount
' Get ColumnsName From 0 to N
' eg: ODyn.FieldName(0) = "MSGID"
Dim str1 As String = ""
Dim str2 As String = ""
'get collumName
For i = 0 To 1000
str1 = _ODyn.FieldName(i)
If str1.Equals(String.Empty) Then
If str2.Length > 0 Then
str2 = Mid(str2, 1, str2.Length - 1)
End If
Exit For
End If
str2 = str2 + str1 + ","
aoTable.Columns.Add(str1, Type.GetType("System.String"))
countC = countC + 1
Next
'aoTable.Rows.Add
For i = 0 To countR - 1
Dim newR As DataRow
newR = aoTable.NewRow
For j = 0 To countC - 1
If TypeOf _ODyn.Item(j).Value Is System.DBNull Then
str1 = "<NULL>"
Else
str1 = CStr(_ODyn.Item(j).Value)
If str1 = "" Then
str1 = "null"
End If
End If
newR(j) = str1
Next j
aoTable.Rows.Add(newR)
_ODyn.MoveNext()
Next i
aoDataSet.Tables.Add(aoTable)
Return aoDataSet
End Function
End Module