gpt4 book ai didi

c# - 减少 Update 和 Sum Query C# Access DB 的时间?

转载 作者:搜寻专家 更新时间:2023-10-30 23:39:15 24 4
gpt4 key购买 nike

我有一个简单的查询,使用 VS2012 C# 的查询生成器更新我的 winforms 应用程序中的数据库。到目前为止,该数据库有 216 个条目,更新数据库需要一生。如何缩短时间?我应该对每一列进行更多查询还是还有其他问题?这是查询:

UPDATE      StudentInfo
SET PLO_1_Status = ?, PLO_2_Status = ?, PLO_3_Status=?,
PLO_4_Status = ?, PLO_5_Status = ?, PLO_6_Status = ?,
PLO_7_Status = ?, PLO_8_Status = ?, PLO_9_Status = ?,
PLO_10_Status = ?, PLO_11_Status = ?, PLO_12_Status = ?
WHERE (CMS_ID = ?)

下面是我如何在 C# 中调用此查询。我正在使用 QueryBuilder 和 DatasetDesigner 以及 Access DB

for (int i = 0; i < CMS_ID_Var.Count; i++)
{
this.studentInfoTableAdapter.UpdatePLO_Overall(
Convert.ToInt32(PercentageFormula_PLO1[i]),
Convert.ToInt32(PercentageFormula_PLO2[i]),
Convert.ToInt32(PercentageFormula_PLO3[i]),
Convert.ToInt32(PercentageFormula_PLO4[i]),
Convert.ToInt32(PercentageFormula_PLO5[i]),
Convert.ToInt32(PercentageFormula_PLO6[i]),
Convert.ToInt32(PercentageFormula_PLO7[i]),
Convert.ToInt32(PercentageFormula_PLO8[i]),
Convert.ToInt32(PercentageFormula_PLO9[i]),
Convert.ToInt32(PercentageFormula_PLO10[i]),
Convert.ToInt32(PercentageFormula_PLO11[i]),
Convert.ToInt32(PercentageFormula_PLO12[i]),
CMS_ID_Var[i].ToString());
this.studentInfoTableAdapter.Fill(this.oBE_DB_1DataSet.StudentInfo);
}

最佳答案

更新表后,在循环外填充一次数据集:

for (int i = 0; i < CMS_ID_Var.Count; i++)
{
this.studentInfoTableAdapter.UpdatePLO_Overall(
Convert.ToInt32(PercentageFormula_PLO1[i]),
Convert.ToInt32(PercentageFormula_PLO2[i]),
Convert.ToInt32(PercentageFormula_PLO3[i]),
Convert.ToInt32(PercentageFormula_PLO4[i]),
Convert.ToInt32(PercentageFormula_PLO5[i]),
Convert.ToInt32(PercentageFormula_PLO6[i]),
Convert.ToInt32(PercentageFormula_PLO7[i]),
Convert.ToInt32(PercentageFormula_PLO8[i]),
Convert.ToInt32(PercentageFormula_PLO9[i]),
Convert.ToInt32(PercentageFormula_PLO10[i]),
Convert.ToInt32(PercentageFormula_PLO11[i]),
Convert.ToInt32(PercentageFormula_PLO12[i]),
CMS_ID_Var[i].ToString());
}
this.studentInfoTableAdapter.Fill(this.oBE_DB_1DataSet.StudentInfo);

关于c# - 减少 Update 和 Sum Query C# Access DB 的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37133091/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com