打印本文 打印本文 关闭窗口 关闭窗口
ADO.NET对象的构造(5)_DataRow(续)
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1740  更新时间:2009/4/23 10:49:52  文章录入:mintao  责任编辑:mintao
    Dim r As DataRow

    For Each t In ds.Tables

       For Each r In t.Rows

          For Each c In t.Columns

             If Not r.IsNull(c) Then Console.WriteLine(r(c).ToString())

          Next c

       Next r

     Next t

 End Sub

 

n          Overloads Public Overridable Function Add(ByVal values() As Object) As DataRow’ 如果在 ColumnChanging 或 RowChanging 事件过程中生成异常,则也可发生异常。如果发生异常,则不向表中添加行。

n          Overloads Public Sub Add(ByVal row As DataRow)’ 如果用户在 RowChanging 事件中生成异常,则生成异常。如果发生异常,则不向表中添加行。

示例

Private Sub AddRow(ByVal myTable As DataTable)

    Dim rc As DataRowCollection= myTable.Rows

    Dim myNewRow As DataRow

 

    Dim rowVals(1) As Object

    rowVals(0) = "hello"

    rowVals(1) = "world"

    myNewRow = rc.Add(rowVals)

 

    newRow = myTable.NewRow()

    newRow(0) = "hello"

    newRow(1) = "world"

    rc.Add(newRow)

 End Sub

(信息整理来自MSDN)

 

上一页  [1] [2] 

打印本文 打印本文 关闭窗口 关闭窗口