How to: Add Rows to a DataTable And DataType Property

剛查了一下 MSDN 的資料
感覺還是自己重新合併的做一次比較實在

  Dim ReturnList As New DataTable
        With ReturnList
            Dim ColSerial As New DataColumn
            ColSerial.DataType = System.Type.GetType("System.Decimal")
            ColSerial.ColumnName = "項次"
            .Columns.Add(ColSerial)
            .Columns.Add("回覆單位")
            .Columns.Add("收件形態")
            .Columns.Add("郵件地址")
            Dim newRow As DataRow = .NewRow()
            newRow("項次") = "serial"
            newRow("回覆單位") = "Dept"
            newRow("收件形態") = "Type"
            newRow("郵件地址") = "@"
            .Rows.Add(newRow)
        End With

Reference: Add Rows to a DataTable ,  DataColumn.DataType Property

沒有留言:

張貼留言