8
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 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 I step through the program, dr is successfully initialized and populated with values, but then after ImportRow(dr), the count of rows in dt is still 0. I feel like I must be missing something obvious. What's going wrong here?