0

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

1 Answer 1

1

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"].

Sign up to request clarification or add additional context in comments.

1 Comment

OMG, Thank you thank you! I cannot believe I was forgetting the [""].

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.