DataTable.ImportRow is not adding rows

后端 未结 4 1799
我寻月下人不归
我寻月下人不归 2021-01-12 07:23

I\'m trying to make a DataTable and then add a couple rows to it. Here\'s my code:

using System;
using System.Collections.Generic;
using System.Linq;
using          


        
4条回答
  •  星月不相逢
    2021-01-12 08:01

    Its May Help you

    DataTable table = new DataTable();
    table.Columns.Add("Dosage", typeof(int));
        table.Columns.Add("Drug", typeof(string));
        table.Columns.Add("Patient", typeof(string));
        table.Columns.Add("Date", typeof(DateTime));
    
        //
        // Here we add five DataRows.
        //
        table.Rows.Add(25, "Indocin", "David", DateTime.Now);
        table.Rows.Add(50, "Enebrel", "Sam", DateTime.Now);
        table.Rows.Add(10, "Hydralazine", "Christoff", DateTime.Now);
        table.Rows.Add(21, "Combivent", "Janet", DateTime.Now);
        table.Rows.Add(100, "Dilantin", "Melanie", DateTime.Now);
    

提交回复
热议问题