UiPath 2024.10 – Fixing Data Type Mismatch in Bulk Insert
If you’re using Bulk Insert in UiPath 2024.10, you may encounter the error:
“Columns have data type mismatch.”
Why Does This Happen?
Even if column names match, their data types might differ between your DataTable and the database table, causing the failure.
How to Fix It?
Clone the DataTable & Convert Columns to String
VB NET:
For Each col As DataColumn In clonedDT.Columns
col.DataType = GetType(String)
Next
LINQ:
clonedDT = originalDT.AsEnumerable().
Select(Function(row) clonedDT.LoadDataRow(row.ItemArray.Select(Function(field) field.ToString()).ToArray(), False)).
CopyToDataTable()
Move Data to the Cloned DataTable
For Each Row + Add Data Row:
For Each row As DataRow In originalDT.Rows
clonedDT.Rows.Add(row.ItemArray)
Next
LINQ:
clonedDT = originalDT.AsEnumerable().CopyToDataTable()
Ensure Database Columns Are NVARCHAR for compatibility.
By ensuring data type consistency, you can seamlessly execute Bulk Insert in UiPath 2024.10 without errors.