c# - DataTable.ImportRow is not adding rows -
i'm trying make datatable , add couple rows it. here's code:
using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.data; namespace thisnamespace { class program { static void main(string[] args) { datatable dt=new datatable(); dt.columns.add("xyzid"); datarow dr=dt.newrow(); dr["xyzid"]=123; dt.importrow(dr); dr["xyzid"] = 604303; dt.importrow(dr); } } }
when step through program, dr
initialized , populated values, after importrow(dr)
, count of rows in dt
still 0. feel must missing obvious. what's going wrong here?
try code:
dt.rows.add(dr)
Comments
Post a Comment