时间:2021-07-01 10:21:17 帮助过:53人阅读
da.UpdateCommand = new SqlCommand(“update Card set ScanFlag = @ScanFlag where CardId = @CardId”, conn);
da.UpdateCommand.Parameters.Add(“@ScanFlag”, SqlDbType.Bit, 1, “ScanFlag”);
da.UpdateCommand.Parameters.Add(“@CardId”, SqlDbType.Int, 4, “CardId”);
da.UpdateCommand.UpdatedRowSource = UpdateRowSource.None;
da.UpdateBatchSize = 0;
for (int i = 0; i < list.Count; i++)
{
for (int j = 0; j < ds.Tables[0].Rows.Count; j++, i++)
{
ds.Tables[0].Rows[j].BeginEdit();
ds.Tables[0].Rows[j][“ScanFlag”] = true;
ds.Tables[0].Rows[j][“CardId”] = list[i].CardId;
ds.Tables[0].Rows[j].EndEdit();
if (i == list.Count – 1)
break;
}
da.Update(ds.Tables[0]);
}
ds.Clear();
ds.Dispose();
}
}
}
C#批量更新sql实例
标签:source mil 更新 end 导出 img ott grid ble