superwei

导航

<2024年11月>
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

统计

常用链接

留言簿(4)

随笔分类

随笔档案

文章分类

文章档案

搜索

最新评论

阅读排行榜

评论排行榜

VB.NET2003 RecordSet转成DataSet代码(原创)

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

posted on 2007-09-27 16:19 小辞猬 阅读(1284) 评论(0)  编辑  收藏 所属分类: DoNet


只有注册用户登录后才能发表评论。


网站导航: