将数据行添加到数据表 [英] Adding datarows to a datatable

查看:108
本文介绍了将数据行添加到数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!



我有一个简单的问题,我现在看不到解决方案。我希望有人可以查明我做错了什么。



主要目标:为数据表创建新的数据行,并为每个数据行添加3列的值。 br />

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.

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);



我看到的错误是:



列table_name不属于表格。



如何引用数据表中列的索引?



(隐藏赋值的注释:tl来自foreach循环,columnQuery_dr.GetString(0)来自SQLCeDataReader检查读取器结束,与waveform_comms_dr.GetString(0)相同)。 />


谢谢大家!


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!

推荐答案

看看这里:



打我* [ ^ ]



这可能就是你要找的东西。
Have a look here:

Clicke me[^]

This might be what you are looking for.


这篇关于将数据行添加到数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆