在csv中插入重复的行

时间:2017-11-23 05:35:31

标签: c# sql csv duplicates

我希望c#代码插入重复行,并在csv文件中添加一些列值。

我的数据表的值为:

Number      Concept  Date      D/C  Customer    Amount
200227026   Test   19.05.2017   01  29009333    30.25

希望将以下内容作为输出:

Number      Concept  Date      D/C  Customer    Amount
200227026   Test   19.05.2017   01  29009333    30.25
200227026   Test   19.05.2017   50  704461      30.25

任何人都可以帮忙吗? 提前致谢

我目前的代码:

DataTable table = new DataTable();
DataColumn dc = new DataColumn("Sr No");
dc.AutoIncrement = true;
dc.AutoIncrementSeed = 1;
dc.AutoIncrementStep = 1;
dc.DataType = typeof(Int32);
table.Columns.Add(dc);
string a = null;
StringBuilder query = new StringBuilder();

using (var con = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString))
using (var cmd = new SqlCommand("test", con))
using (var da = new SqlDataAdapter(cmd))
{
cmd.CommandType = CommandType.StoredProcedure;
table.BeginLoadData();
da.Fill(table);
DataTableReader dtReader = new DataTableReader(table);
table.Load(dtReader);
table.EndLoadData();
}

sendreport(table, "", "test");

0 个答案:

没有答案