superwei

          導(dǎo)航

          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          統(tǒng)計(jì)

          常用鏈接

          留言簿(4)

          隨筆分類

          隨筆檔案

          文章分類

          文章檔案

          搜索

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

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

          主站蜘蛛池模板: 通城县| 高雄县| 东至县| 永定县| 桦川县| 乳源| 长葛市| 苍溪县| 城步| 克拉玛依市| 武平县| 浮梁县| 盐城市| 吉木萨尔县| 隆尧县| 湟中县| 新闻| 武清区| 江油市| 依兰县| 广南县| 泰兴市| 弥勒县| 沁水县| 独山县| 龙州县| 互助| 临湘市| 平凉市| 南平市| 阆中市| 逊克县| 临武县| 眉山市| 习水县| 台江县| 崇州市| 江油市| 韶山市| 宜都市| 凤阳县|