c#datatable参数 [英] c# datatable parameter
本文介绍了c#datatable参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
如何从参数向datatable添加值?我试过下面的代码,但它只添加了一个和相同的参数。
Hello
How to add values to datatable from parameter?I tried below code but it just added only ones and the same parameter.
public DataTable create(string a)
{
DataTable dt = new DataTable();
dt.Columns.Add("Saheler",typeof(String));
DataRow row = dt.NewRow();
row[0] = a;
dt.Rows.Add(row);
}
推荐答案
我认为你需要考虑拆分这个
I think you need to consider splitting this
public DataTable create(string a)
{
DataTable dt = new DataTable();
dt.Columns.Add("Saheler",typeof(String));
DataRow row = dt.NewRow();
row[0] = a;
dt.Rows.Add(row);
}
进入像
Into Something like
public DataTable create(string a)
{
DataTable dt = new DataTable();
dt.Columns.Add("Saheler",typeof(String));
return dt;
}
public AddRowToDT(ref Datatable dt, String Parameter)
{
DataRow row = dt.NewRow();
row[0] = Parameter;
dt.Rows.Add(row);
}
鉴于你对你要做的事情的描述...
如果你想进一步详细说明,并且更具体一点,你可能会得到一个更好的答案
Given your description of what you''re trying to do ...
If you want to elaborate further, and be a bit more specific, you might get a better answer
这篇关于c#datatable参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文