Bug #111670 Occured NullReferenceException at GetCommandTextForBatching
Submitted: 6 Jul 2023 4:05 Modified: 7 Jul 2023 5:05
Reporter: yonghun shin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version:8.0.33 OS:Windows
Assigned to: CPU Architecture:Any
Tags: batch inserts, GetCommandTextForBatching, NullReferenceException

[6 Jul 2023 4:05] yonghun shin
Description:
 When insert mutiple rows using MySqlDataAdapter.Update with UpdateBatchSize > 1 or 0 (i.e. use batch mode) by generated InsertCommand by MySqlCommandBuilder,
occured NullReferenceException at GetCommandTextForBatching

How to repeat:
Update DataTable below codes

adapter.Update(table.Select(null, null, DataViewRowState.Deleted));   // some deleted rows
adapter.Update(table.Select(null, null, DataViewRowState.ModifiedCurrent)); // some modified rows
adapter.Update(table.Select(null, null, DataViewRowState.Added)); // more then 2 rows

Suggested fix:
I don't have any idea
[6 Jul 2023 13:14] MySQL Verification Team
Hello!

Thank you for the bug report.
Could you please provide repeatable test case(c# class) to reproduce this issue at our end? Thanks.

Regards,
Ashwini Patil
[7 Jul 2023 5:05] yonghun shin
I was creating MySqlDataAdapter once and calling MySqlDataAdapter.Update(...) over and over again.

If you call it as above, an exception will occur during Batch Inserts from the second call.

When calling MySqlDataAdapter.Update(...), I confirmed that if MySqlDataAdapter is created every time, it works normally.

Thank you