superwei

          導航

          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          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 小辭猬 閱讀(1295) 評論(0)  編輯  收藏 所屬分類: DoNet

          主站蜘蛛池模板: 洛阳市| 东山县| 余庆县| 湖南省| 莱西市| 江口县| 潮安县| 旬邑县| 铜川市| 大冶市| 建瓯市| 武清区| 新巴尔虎左旗| 黄骅市| 吴堡县| 罗甸县| 扬中市| 焉耆| 安顺市| 通州市| 昂仁县| 图们市| 临泽县| 中阳县| 龙南县| 金沙县| 大姚县| 乌鲁木齐县| 诸城市| 常德市| 丰原市| 肥乡县| 秀山| 成安县| 兴和县| 疏附县| 西盟| 台南县| 巫溪县| 衢州市| 张家港市|