我使用以下代码将sql表中的值加载到数据表中。
我会尽力为您翻译以下内容,这是关于IT技术方面的问题:
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection("Connection String Here");
con.Open();
SqlCommand cmd = new SqlCommand("select * from ExportExcel", con);
dt.Load(cmd.ExecuteReader());
int total = 0;
foreach (DataRow row in dt.Rows)
{
int salaryvalue = Convert.ToInt32(row["Salary"]);
total = salaryvalue + total;
}
dt.Rows.Add("Salary");
dt.Rows.Add(total);
我会尽力为您翻译以下内容,这是关于IT技术方面的问题:
我动态地添加了薪水总和,但它们一个接一个地显示在第一列中。
但是我需要在部门列中显示薪水,在薪水列中显示总和。应该如何处理?