superwei

          導(dǎo)航

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          統(tǒng)計

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          VB.NET2003 RecordSet轉(zhuǎn)成DataSet代碼(原創(chuàng))

          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 小辭猬 閱讀(1295) 評論(0)  編輯  收藏 所屬分類: DoNet

          主站蜘蛛池模板: 永清县| 平凉市| 宁乡县| 京山县| 遂溪县| 江华| 宁晋县| 和顺县| 镇江市| 平顶山市| 德庆县| 什邡市| 广丰县| 金乡县| 浮梁县| 双江| 剑阁县| 海城市| 称多县| 安达市| 普定县| 涞水县| 连平县| 武定县| 嘉兴市| 阿坝县| 木兰县| 横峰县| 天峨县| 武定县| 沽源县| 栾城县| 垣曲县| 宣化县| 阿巴嘎旗| 原平市| 阿克苏市| 南和县| 蒙自县| 岐山县| 嵩明县|