我正在使用一个try catch块通过ADO.NET2.0进行批处理更新,UpdateBatchSize设置为500,我经常可以捕获异常,但我不知道哪一行更新失败了,有没有办法获得实际失败的行?
发布于 2012-09-24 12:18:33
您可以使用event RowUpdated获取row的引用:
yourAdapter.RowUpdated += OnRowUpdated;然后:
protected static void OnRowUpdated(object sender, SqlRowUpdatedEventArgs args)
{
if (args.Status == UpdateStatus.ErrorsOccurred)
{
// Reference to row which throws error
var row = args.Row;
row.RowError = args.Errors.Message;
args.Status = UpdateStatus.SkipCurrentRow;
// Do something more
}
}https://stackoverflow.com/questions/12558354
复制相似问题