Reputation: 13
I cant seem to add a value to a datatable in C#. I have done my research and cannot figure out what I am missing. I can print the value to console but when I try to assign and add System.Data.DataRow. Its probably a simple solution but I cannot figure it out to save the life of me.
worktable is new datatable
foreach(var ts in timeSeries_ind)
{
Bar mbar = ts as Bar;
DataRow newr = workTable.NewRow();
newr["Date/Time"] = mbar.DateTime;
Console.WriteLine(mbar.DateTime);
workTable.Rows.Add(newr); //newr
Console.WriteLine(newr.ToString());
}
Firstline prints fine to console Second when trying to view Data.DataRow
Upvotes: 0
Views: 78
Reputation: 126
You can't print a complete DataRow, you need to specify which field of the DataRow you want to print. For example (string)newr["Date/Time"]
.
Upvotes: 1