如何在C#中将数据添加到现有数据表列中 [英] how to add data to existing Data table Column in c#
本文介绍了如何在C#中将数据添加到现有数据表列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将数据添加到c#.net中的现有数据表"列中可以提供任何帮助
I would like add data to Existing Datatable column in c#.net can any one help
推荐答案
看看这些MSDN文章:
如何:将行添加到数据表 [ ^ ]
将列添加到表中 [
Have a look on these MSDN articles:
How to: Add Rows to a DataTable[^]
Adding Columns to a Table [^]
And have a look on following examples for reference:
foreach(int i in collections)
{
DataRow row = dt.NewRow();
row["NewRecord"] = textbox1.text.ToString();
dt.Rows.Add(newRow);
}
DataTable workTable = new DataTable("Customers");
DataColumn workCol = workTable.Columns.Add("CustID", typeof(Int32));
workCol.AllowDBNull = false;
workCol.Unique = true;
workTable.Columns.Add("CustLName", typeof(String));
workTable.Columns.Add("CustFName", typeof(String));
workTable.Columns.Add("Purchases", typeof(Double));
这样,您可以将行添加到DataTable
Like this you can add rows to your DataTable
这篇关于如何在C#中将数据添加到现有数据表列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文