Click here to Skip to main content
15,868,292 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi everyone!

I have a simple issue that I can't see a resolution for right now. I'm hoping someone can pinpoint what I'm doing wrong.

Main goal: Create new datarows for a datatable and add values for 3 columns to each datarow.
C#
DataTable waveform_file_dt = new DataTable();
DataRow newRow = waveform_file_dt.NewRow();

newRow["table_name"] = tl;
newRow["column_name"] = columnQuery_dr.GetString(0);
newRow["waveform_file"] = waveform_comms_dr.GetString(0) + ".psdata";
waveform_file_dt.Rows.Add(newRow);

The error I'm seeing is :

Column "table_name" does not belong to table.

How can I reference the index of the column in the datatable?

(Notes for cryptic assignments: "tl" is from a foreach loop, columnQuery_dr.GetString(0) is from a SQLCeDataReader check for end of reader and same with waveform_comms_dr.GetString(0)).

Thank you everyone!
Posted
Updated 7-Jun-13 9:49am
v2

1 solution

Have a look here:

Clicke me[^]

This might be what you are looking for.
 
Share this answer
 
Comments
joshrduncan2012 7-Jun-13 16:19pm    
Yep, that did it. Thanks Rich!
Richard C Bishop 7-Jun-13 16:21pm    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900